<?php
class Helper
{
/**
* 用于设置数据写入和查询是否严格检查是否存在字段。
* 默认情况下不合法数据字段自动删除,如果设置了严格检查则会抛出异常
* 如:
* strict(true)
*
* @param bool $strict
* @return static
*/
public function strict($strict)
{
return $this;
}
/**
* 排序
* 例如:
* order('id desc')
* order('id desc,status')
* order(['order', 'id' => 'desc'])
*
* @param array|string $order
* @return static
*/
public function order($order)
{
return $this;
}
/**
* alias用于设置当前数据表的别名,便于使用其他的连贯操作例如join方法等。
* 如:
* alias('a')->where('a.id > 4')
*
* @param string $alias 别名
* @return static
*/
public function alias($alias)
{
return $this;
}
/**
* HAVING方法也是连贯操作之一,用于配合group方法完成从分组的结果中筛选(通常是聚合条件)数据。
* having 方法只有一个参数,并且只能使用字符串
* 如:
* having('count(test_time)>3')
*
* @param string $having
* @return $this
*/
public function having($having)
{
return $this;
}
/**
* GROUP方法也是连贯操作方法之一,通常用于结合合计函数,根据一个或多个列对结果集进行分组 。
* group 方法只有一个参数,并且只能使用字符串
* 如:
* group('user_id')
* group('user_id,test_time')
*
* @param string $group
* @return $this
*/
public function group($group)
{
return $this;
}
/**
* 用于数据库的锁机制,如果在查询或者执行操作的时候使用:
* 如果使用了lock(true),就会在最后加上for update或for update nowait(Oracle)
*
* @param bool $lock
* @return $this
*/
public function lock($lock)
{}
/**
* 用于返回唯一不同的值
* 如:
* $Model->distinct(true)->field('name')->select();
* 会生成:
* select distinct name from xxx
*
* @param bool $distinct
* @return $this
*/
public function distinct($distinct)
{
return $this;
}
/**
* 用于数据自动完成
*
* @param array $auto
* @return $this
*/
public function auto($auto = [])
{
return $this;
}
/**
* 过滤
*
* @param string $filter 过滤函数名
* @return $this
*/
public function filter($filter)
{
return $this;
}
/**
* 用于数据自动验证
*
* @param array $validate
* @return $this
*/
public function validate($validate = [])
{
return $this;
}
/**
* 用于返回数据转换
*
* @param string $result
* @return $this
*/
public function result($result = '')
{
return $this;
}
/**
* 用于令牌验证
*
* @param bool $token
* @return $this
*/
public function token($token)
{
return $this;
}
/**
* 用于数据集的强制索引操作
*
* @param string $index 必须是数据表实际创建的索引名称
* @return $this
*/
public function index($index)
{
return $this;
}
// 未知
public function force()
{}
// 以下是统计函数
/**
* @param string $column 要统计的列
* @return integer
*/
public function count($column = '')
{
}
/**
* @param string $column 要统计的列
* @return mixed
*/
public function sum($column)
{
}
/**
* @param string $column 要统计的列
* @return mixed
*/
public function min($column)
{
}
/**
* @param string $column 要统计的列
* @return mixed
*/
public function max($column)
{
}
/**
* @param string $column 要统计的列
* @return mixed
*/
public function avg($column)
{
}
}
可以放在 gitignore 的文件夹下,然后在 Model.class.php 文件上面加注释,@mixin \Helper
转载于:https://www.cnblogs.com/eleven24/p/7665354.html