本文整理汇总了PHP中rcube_db::limitquery方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db::limitquery方法的具体用法?PHP rcube_db::limitquery怎么用?PHP rcube_db::limitquery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_db
的用法示例。
在下文中一共展示了rcube_db::limitquery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: abs
/**
* List the current set of contact records
*
* @param array List of cols to show, Null means all
* @param int Only return this number of records, use negative values for tail
* @param boolean True to skip the count query (select only)
* @return array Indexed list of contact records, each a hash array
*/
function list_records($cols = null, $subset = 0, $nocount = false)
{
if ($nocount || $this->list_page <= 1) {
// create dummy result, we don't need a count now
$this->result = new rcube_result_set();
} else {
// count all records
$this->result = $this->count();
}
$start_row = $subset < 0 ? $this->result->first + $this->page_size + $subset : $this->result->first;
$length = $subset != 0 ? abs($subset) : $this->page_size;
if ($this->group_id) {
$join = " LEFT JOIN " . $this->db->table_name($this->db_groupmembers) . " AS m" . " ON (m.contact_id = c." . $this->primary_key . ")";
}
$order_col = in_array($this->sort_col, $this->table_cols) ? $this->sort_col : 'name';
$order_cols = array('c.' . $order_col);
if ($order_col == 'firstname') {
$order_cols[] = 'c.surname';
} else {
if ($order_col == 'surname') {
$order_cols[] = 'c.firstname';
}
}
if ($order_col != 'name') {
$order_cols[] = 'c.name';
}
$order_cols[] = 'c.email';
$sql_result = $this->db->limitquery("SELECT * FROM " . $this->db->table_name($this->db_name) . " AS c" . $join . " WHERE c.del<>1" . " AND c.user_id=?" . ($this->group_id ? " AND m.contactgroup_id=?" : "") . ($this->filter ? " AND (" . $this->filter . ")" : "") . " ORDER BY " . $this->db->concat($order_cols) . " " . $this->sort_order, $start_row, $length, $this->user_id, $this->group_id);
// determine whether we have to parse the vcard or if only db cols are requested
$read_vcard = !$cols || count(array_intersect($cols, $this->table_cols)) < count($cols);
while ($sql_result && ($sql_arr = $this->db->fetch_assoc($sql_result))) {
$sql_arr['ID'] = $sql_arr[$this->primary_key];
if ($read_vcard) {
$sql_arr = $this->convert_db_data($sql_arr);
} else {
$sql_arr['email'] = explode(self::SEPARATOR, $sql_arr['email']);
$sql_arr['email'] = array_map('trim', $sql_arr['email']);
}
$this->result->add($sql_arr);
}
$cnt = count($this->result->records);
// update counter
if ($nocount) {
$this->result->count = $cnt;
} else {
if ($this->list_page <= 1) {
if ($cnt < $this->page_size && $subset == 0) {
$this->result->count = $cnt;
} else {
if (isset($this->cache['count'])) {
$this->result->count = $this->cache['count'];
} else {
$this->result->count = $this->_count();
}
}
}
}
return $this->result;
}
示例2: read_record
/**
* Reads cache entry.
*
* @param string $key Cache key name
* @param boolean $nostore Enable to skip in-memory store
*
* @return mixed Cached value
*/
private function read_record($key, $nostore = false)
{
if (!$this->db) {
return null;
}
if ($this->type != 'db') {
$this->load_index();
// Consistency check (#1490390)
if (!in_array($key, $this->index)) {
// we always check if the key exist in the index
// to have data in consistent state. Keeping the index consistent
// is needed for keys delete operation when we delete all keys or by prefix.
} else {
$ckey = $this->ckey($key);
if ($this->type == 'memcache') {
$data = $this->db->get($ckey);
} else {
if ($this->type == 'apc') {
$data = apc_fetch($ckey);
}
}
if ($this->debug) {
$this->debug('get', $ckey, $data);
}
}
if ($data) {
$md5sum = md5($data);
$data = $this->unserialize($data);
if ($nostore) {
return $data;
}
$this->cache_sums[$key] = $md5sum;
$this->cache[$key] = $data;
} else {
$this->cache[$key] = null;
}
} else {
$sql_result = $this->db->limitquery("SELECT `data`, `cache_key`" . " FROM {$this->table}" . " WHERE `user_id` = ? AND `cache_key` = ?" . " ORDER BY `created` DESC", 0, 1, $this->userid, $this->prefix . '.' . $key);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$key = substr($sql_arr['cache_key'], strlen($this->prefix) + 1);
$md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
if ($sql_arr['data']) {
$data = $this->unserialize($sql_arr['data']);
}
if ($nostore) {
return $data;
}
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
} else {
$this->cache[$key] = null;
}
}
return $this->cache[$key];
}
示例3: read_record
/**
* Reads cache entry.
*
* @param string $key Cache key name
* @param boolean $nostore Enable to skip in-memory store
*
* @return mixed Cached value
*/
private function read_record($key, $nostore = false)
{
if (!$this->db) {
return null;
}
if ($this->type != 'db') {
if ($this->type == 'memcache') {
$data = $this->db->get($this->ckey($key));
} else {
if ($this->type == 'apc') {
$data = apc_fetch($this->ckey($key));
}
}
if ($data) {
$md5sum = md5($data);
$data = $this->unserialize($data);
if ($nostore) {
return $data;
}
$this->cache_sums[$key] = $md5sum;
$this->cache[$key] = $data;
} else {
$this->cache[$key] = null;
}
} else {
$sql_result = $this->db->limitquery("SELECT data, cache_key" . " FROM " . $this->table . " WHERE user_id = ?" . " AND cache_key = ?" . " ORDER BY created DESC", 0, 1, $this->userid, $this->prefix . '.' . $key);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$key = substr($sql_arr['cache_key'], strlen($this->prefix) + 1);
$md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
if ($sql_arr['data']) {
$data = $this->unserialize($sql_arr['data']);
}
if ($nostore) {
return $data;
}
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
} else {
$this->cache[$key] = null;
}
}
return $this->cache[$key];
}
示例4: read_record
/**
* Reads cache entry.
*
* @param string $key Cache key name
* @param boolean $nostore Enable to skip in-memory store
*
* @return mixed Cached value
*/
private function read_record($key, $nostore = false)
{
if (!$this->db) {
return null;
}
if ($this->type != 'db') {
if ($this->type == 'memcache') {
$data = $this->db->get($this->ckey($key));
} else {
if ($this->type == 'apc') {
$data = apc_fetch($this->ckey($key));
}
}
if ($data) {
$md5sum = md5($data);
$data = $this->unserialize($data);
if ($nostore) {
return $data;
}
$this->cache_sums[$key] = $md5sum;
$this->cache[$key] = $data;
} else {
$this->cache[$key] = null;
}
} else {
$sql_result = $this->db->limitquery("SELECT `data`, `cache_key`" . " FROM {$this->table}" . " WHERE `cache_key` = ?" . " ORDER BY `created` DESC", 0, 1, $this->prefix . '.' . $key);
if ($sql_arr = $this->db->fetch_assoc($sql_result)) {
$md5sum = $sql_arr['data'] ? md5($sql_arr['data']) : null;
if ($sql_arr['data']) {
$data = $this->unserialize($sql_arr['data']);
}
if ($nostore) {
return $data;
}
$this->cache[$key] = $data;
$this->cache_sums[$key] = $md5sum;
} else {
$this->cache[$key] = null;
}
}
return $this->cache[$key];
}