本文整理汇总了PHP中Versions::query方法的典型用法代码示例。如果您正苦于以下问题:PHP Versions::query方法的具体用法?PHP Versions::query怎么用?PHP Versions::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Versions
的用法示例。
在下文中一共展示了Versions::query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: history
/**
* Get recent versions of an object, or of objects of a specific
* class. If `$limit` is set to `true` (boolean), it will return
* a count of the history.
*/
public static function history($obj, $limit = 10, $offset = 0)
{
if ($limit === true) {
// return a count instead of the results
if (is_string($obj)) {
// return for a class type
return count(Versions::query()->where('class', $obj)->group('pkey')->fetch_field('pkey'));
}
// return for an individual object
return count(Versions::query()->where('class', get_class($obj))->where('pkey', $obj->{$obj->key})->fetch_field('pkey'));
}
if (is_string($obj)) {
// return for a class type
if (!is_numeric($limit)) {
return array();
}
if (!is_numeric($offset)) {
return array();
}
return DB::fetch('select * from `#prefix#versions`
where `id` in
(select max(`id`) from `#prefix#versions`
where `class` = ?
group by `pkey`)
order by `ts` desc
limit ' . $limit . ' offset ' . $offset, $obj);
}
// return for an individual object
return Versions::query()->where('class', get_class($obj))->where('pkey', $obj->{$obj->key})->order('ts desc')->fetch_orig($limit, $offset);
}
示例2: history
/**
* Get recent versions of an object, or of objects of a specific
* class. If `$limit` is set to `true` (boolean), it will return
* a count of the history.
*/
public static function history($obj, $limit = 10, $offset = 0)
{
if ($limit === true) {
if (is_string($obj)) {
return count(Versions::query()->where('class', $obj)->group('pkey')->fetch_field('pkey'));
}
return count(Versions::query()->where('class', get_class($obj))->where('pkey', $obj->{$obj->key})->fetch_field('pkey'));
}
if (is_string($obj)) {
return Versions::query()->where('class', $obj)->order('ts desc')->group('pkey')->fetch_orig($limit, $offset);
}
return Versions::query()->where('class', get_class($obj))->where('pkey', $obj->{$obj->key})->order('ts desc')->fetch_orig($limit, $offset);
}