BaseModel.php 815 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\model;
  3. use think\facade\Config;
  4. use think\Model;
  5. class BaseModel extends Model
  6. {
  7. /**
  8. * @var bool 自动写入2019年8月14日 12:32:24
  9. */
  10. protected $autoWriteTimestamp = true;
  11. protected $createTime = 'create_time';
  12. protected $updateTime = 'update_time';
  13. public function __construct(array $data = [])
  14. {
  15. parent::__construct($data);
  16. }
  17. public static function getList($where = array(), $pageSize, $order = ['sort', 'id' => 'desc'])
  18. {
  19. return self::where($where)->where($order)->select();
  20. }
  21. public static function getOne($id)
  22. {
  23. return self::find($id);
  24. }
  25. //表前缀
  26. public static function get_table_prefix(){
  27. return Config::get('database.connections.mysql.prefix');
  28. }
  29. }