public function __call($method, $args)
{
if (strtolower(substr($method, 0, 5)) == 'getby') {
// 根据某个字段获取记录
$field = Loader::parseName(substr($method, 5));
$where[$field] = $args[0];
return $this->where($where)->find();
} elseif (strtolower(substr($method, 0, 10)) == 'getfieldby') {
// 根据某个字段获取记录的某个值
$name = Loader::parseName(substr($method, 10));
$where[$name] = $args[0];
return $this->where($where)->value($args[1]);
} else {
throw new Exception('method not exist:' . __CLASS__ . '->' . $method);
}
}
thinkphp Db类
最新推荐文章于 2024-08-25 14:01:17 发布