123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Bear
- * Date: 2020/6/5
- * Time: 下午4:13
- */
- namespace app\source\model;
- abstract class InitModel implements ModelInterface
- {
- //主键
- public $pk = '';
- public static $self;
- /**
- * 绑定参数
- * @param $data
- * @return static
- */
- public function bind($data)
- {
- foreach ($data as $key => $value) {
- $this->$key = $value;
- }
- return $this;
- }
- /**
- * 转化为数组
- * @return mixed
- */
- public function toArray()
- {
- $data = [];
- foreach ($this as $field => $value) {
- $data[$field] = $value;
- }
- return $data;
- }
- }
|