ThinkPHP 5 模型使用历程 - IDE友好

文件多了,代码多了,提示和穿透是很必要的功能,我用的phpstorm

phpdoc

通过注释,可以快速查找到相关的代码,比较常用的是:
@param,@property,@return,@deprecated,@var,@method,@see

/**
 * 模型基类
 *
 * @method $this where(array|string $field, string $op = NULL, mixed $condition = NULL) static 查询条件
 * @method $this field(string $field, boolean $except = FALSE) static 字段
 * @method $this with(mixed $with) static 关联
 * @method $this find(mixed $data = NULL) static 单条查询
 * @method $this order(string $field, string $order = NULL) static 排序
 * @method Collection|array|\PDOStatement|string select(mixed $data = NULL) static 查询多个记录
 * @method $this limit(int|mixed $offset, integer $length = NULL) static 查询LIMIT
 * @method $this fieldRaw(string $field, array $bind = []) static 指定查询字段
 * @method $this count(string $field = '*') static Count统计查询
 * @method $this delete() 删除数据
 * @method $this withAttr(string $name,\Closure $closure) 动态定义获取器
 * @method float sum(string $field) static SUM统计查询
 *
 * @package etop\model\table
 */
class MTBase extends Model
{
}

少用快捷方法和反射

从来不用model()之类的快捷方法,直接用$user = new MTUser();

本作品采用《CC 协议》,转载必须注明作者和本文链接
秦晓武
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!