[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 ``` ```