本文整理汇总了PHP中Statement::_count方法的典型用法代码示例。如果您正苦于以下问题:PHP Statement::_count方法的具体用法?PHP Statement::_count怎么用?PHP Statement::_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Statement
的用法示例。
在下文中一共展示了Statement::_count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
*
* @param Request $request
* @param stdClass $user
* @param array $limit
* @return \self
*/
public static function get(Request $request, stdClass $user, array $limit = array('offset' => 0, 'limit' => 10))
{
$where = array();
$where_str = '';
if ($request->has('show') && $request->get('show') == 'filter') {
if ($request->has('type')) {
$where[] = "s.type IN ('" . implode("', '", (array) $request->get('type')) . "')";
}
if ($request->has('categories')) {
$where[] = "category IN ('" . implode("', '", (array) $request->get('categories')) . "')";
}
if ($request->has('status')) {
$where[] = "status IN ('" . implode("', '", (array) $request->get('status')) . "')";
}
if ($request->has('time')) {
switch ($request->get('time')) {
case 'today':
$where[] = "date > " . mktime(0, 0, 0, date('n'), date('d'), date('Y'));
break;
case 'week':
$where[] = "date > " . time() - 7 * 24 * 3600;
break;
case 'month':
$where[] = "date > " . time() - 30 * 24 * 3600;
break;
default:
break;
}
}
if ($where) {
$where_str = "WHERE " . implode(' AND ', $where) . " ";
}
}
switch ($request->get('order')) {
default:
case 'vote':
$order = ' ORDER BY (plus_count - minus_count) DESC ';
break;
case 'date':
$order = ' ORDER BY `date` DESC ';
break;
case 'comments':
$order = ' ORDER BY `comm_num` DESC ';
break;
}
$count_query = "SELECT COUNT(*)AS count FROM " . PREFIX . "_statement AS s " . $where_str;
$count = self::$db->super_query($count_query);
self::$_count = $count['count'];
$query = "SELECT s.*, l.statement_id AS isset FROM " . PREFIX . "_statement AS s\n LEFT JOIN " . PREFIX . "_statement_log AS l\n ON l.statement_id=s.id AND ((l.user_id AND l.user_id={$user->user_id}) OR l.ip_address='" . $user->ip_address . "')\n {$where_str}{$order}LIMIT " . $limit['offset'] . ", " . $limit['limit'];
self::$db->query($query);
$sts = array();
while ($row = self::$db->get_row()) {
$sts[] = new self($row);
}
return $sts;
}