多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 概述 用于定义表结构,过滤掉无效字段数据。 ### 简单 demo ``` class Apple extends \EasySwoole\Spl\SplBean { protected $name; protected $price; protected $number; protected function setKeyMapping(): array { return ['price' => 'as']; } } $apple = new Apple(['name' => 'test', 'price' => 12, 'number' => 12, 'age' => 2], true); print_r($apple->toArray()); print_r($apple->toArrayWithMapping()); echo '---------------------------------------'.PHP_EOL; $apple->restore(['name' => 'blank', 'price' => 12, 'number' => 12]); print_r($apple->toArray()); print_r($apple->toArrayWithMapping()); ``` ## 配合 Model 使用 Model/user/user.php ``` ```