当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_db::affected_rows方法代码示例

本文整理汇总了PHP中rcube_db::affected_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db::affected_rows方法的具体用法?PHP rcube_db::affected_rows怎么用?PHP rcube_db::affected_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rcube_db的用法示例。


在下文中一共展示了rcube_db::affected_rows方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: write_record

 /**
  * Writes single cache record into DB.
  *
  * @param string $key  Cache key name
  * @param mxied  $data Serialized cache data 
  *
  * @param boolean True on success, False on failure
  */
 private function write_record($key, $data)
 {
     if (!$this->db) {
         return false;
     }
     if ($this->type == 'memcache' || $this->type == 'apc') {
         return $this->add_record($this->ckey($key), $data);
     }
     $key_exists = array_key_exists($key, $this->cache_sums);
     $key = $this->prefix . '.' . $key;
     // Remove NULL rows (here we don't need to check if the record exist)
     if ($data == 'N;') {
         $this->db->query("DELETE FROM " . $this->table . " WHERE user_id = ?" . " AND cache_key = ?", $this->userid, $key);
         return true;
     }
     // update existing cache record
     if ($key_exists) {
         $result = $this->db->query("UPDATE " . $this->table . " SET created = " . $this->db->now() . ", expires = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", data = ?" . " WHERE user_id = ?" . " AND cache_key = ?", $data, $this->userid, $key);
     } else {
         // for better performance we allow more records for one key
         // so, no need to check if record exist (see rcube_cache::read_record())
         $result = $this->db->query("INSERT INTO " . $this->table . " (created, expires, user_id, cache_key, data)" . " VALUES (" . $this->db->now() . ", " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", ?, ?, ?)", $this->userid, $key, $data);
     }
     return $this->db->affected_rows($result);
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:33,代码来源:rcube_cache.php

示例2: write_record

 /**
  * Writes single cache record into DB.
  *
  * @param string $key  Cache key name
  * @param mixed  $data Serialized cache data
  *
  * @param boolean True on success, False on failure
  */
 private function write_record($key, $data)
 {
     if (!$this->db) {
         return false;
     }
     // don't attempt to write too big data sets
     if (strlen($data) > $this->max_packet_size()) {
         trigger_error("rcube_cache: max_packet_size ({$this->max_packet}) exceeded for key {$key}. Tried to write " . strlen($data) . " bytes", E_USER_WARNING);
         return false;
     }
     if ($this->type == 'memcache' || $this->type == 'apc') {
         return $this->add_record($this->ckey($key), $data);
     }
     $key_exists = array_key_exists($key, $this->cache_sums);
     $key = $this->prefix . '.' . $key;
     // Remove NULL rows (here we don't need to check if the record exist)
     if ($data == 'N;') {
         $this->db->query("DELETE FROM {$this->table} WHERE `cache_key` = ?", $key);
         return true;
     }
     // update existing cache record
     if ($key_exists) {
         $result = $this->db->query("UPDATE {$this->table}" . " SET `created` = " . $this->db->now() . ", `expires` = " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", `data` = ?" . " WHERE `cache_key` = ?", $data, $key);
     } else {
         // for better performance we allow more records for one key
         // so, no need to check if record exist (see rcube_cache::read_record())
         $result = $this->db->query("INSERT INTO {$this->table}" . " (`created`, `expires`, `cache_key`, `data`)" . " VALUES (" . $this->db->now() . ", " . ($this->ttl ? $this->db->now($this->ttl) : 'NULL') . ", ?, ?)", $key, $data);
     }
     return $this->db->affected_rows($result);
 }
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:38,代码来源:rcube_cache_shared.php

示例3: serialize

 /**
  * Saves the message in cache.
  *
  * @param string               $mailbox  Folder name
  * @param rcube_message_header $message  Message data
  * @param bool                 $force    Skips message in-cache existance check
  */
 function add_message($mailbox, $message, $force = false)
 {
     if (!is_object($message) || empty($message->uid)) {
         return;
     }
     $msg = serialize($this->db->encode(clone $message));
     $flags = 0;
     if (!empty($message->flags)) {
         foreach ($this->flags as $idx => $flag) {
             if (!empty($message->flags[$flag])) {
                 $flags += $idx;
             }
         }
     }
     unset($msg->flags);
     // update cache record (even if it exists, the update
     // here will work as select, assume row exist if affected_rows=0)
     if (!$force) {
         $res = $this->db->query("UPDATE " . $this->db->table_name('cache_messages') . " SET flags = ?, data = ?, changed = " . $this->db->now() . " WHERE user_id = ?" . " AND mailbox = ?" . " AND uid = ?", $flags, $msg, $this->userid, $mailbox, (int) $message->uid);
         if ($this->db->affected_rows()) {
             return;
         }
     }
     // insert new record
     $this->db->query("INSERT INTO " . $this->db->table_name('cache_messages') . " (user_id, mailbox, uid, flags, changed, data)" . " VALUES (?, ?, ?, ?, " . $this->db->now() . ", ?)", $this->userid, $mailbox, (int) $message->uid, $flags, $msg);
 }
开发者ID:rockchow2002,项目名称:roundcubemail,代码行数:33,代码来源:rcube_imap_cache.php

示例4:

 /**
  * Deletes given saved search record
  *
  * @param  int  $sid  Search ID
  *
  * @return boolean True if deleted successfully, false if nothing changed
  */
 function delete_search($sid)
 {
     if (!$this->ID) {
         return false;
     }
     $this->db->query("DELETE FROM " . $this->db->table_name('searches') . " WHERE user_id = ?" . " AND search_id = ?", (int) $this->ID, $sid);
     return $this->db->affected_rows();
 }
开发者ID:alecchisi,项目名称:roundcubemail,代码行数:15,代码来源:rcube_user.php

示例5: explode

 /**
  * Remove the given contact records from a certain group
  *
  * @param string  Group identifier
  * @param array   List of contact identifiers to be removed
  * @return int    Number of deleted group members
  */
 function remove_from_group($group_id, $ids)
 {
     if (!is_array($ids)) {
         $ids = explode(self::SEPARATOR, $ids);
     }
     $ids = $this->db->array2list($ids, 'integer');
     $sql_result = $this->db->query("DELETE FROM " . $this->db->table_name($this->db_groupmembers) . " WHERE contactgroup_id=?" . " AND contact_id IN ({$ids})", $group_id);
     return $this->db->affected_rows();
 }
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:16,代码来源:rcube_contacts.php

示例6: write_record

 /**
  * Writes single cache record into DB.
  *
  * @param string $key  Cache key name
  * @param mixed  $data Serialized cache data
  *
  * @param boolean True on success, False on failure
  */
 private function write_record($key, $data)
 {
     if (!$this->db) {
         return false;
     }
     // don't attempt to write too big data sets
     if (strlen($data) > $this->max_packet_size()) {
         trigger_error("rcube_cache: max_packet_size ({$this->max_packet}) exceeded for key {$key}. Tried to write " . strlen($data) . " bytes", E_USER_WARNING);
         return false;
     }
     if ($this->type == 'memcache' || $this->type == 'apc') {
         $result = $this->add_record($this->ckey($key), $data);
         // make sure index will be updated
         if ($result) {
             if (!array_key_exists($key, $this->cache_sums)) {
                 $this->cache_sums[$key] = true;
             }
             $this->load_index();
             if (!$this->index_changed && !in_array($key, $this->index)) {
                 $this->index_changed = true;
             }
         }
         return $result;
     }
     $db_key = $this->prefix . '.' . $key;
     // Remove NULL rows (here we don't need to check if the record exist)
     if ($data == 'N;') {
         $result = $this->db->query("DELETE FROM {$this->table} WHERE `cache_key` = ?", $db_key);
         return !$this->db->is_error($result);
     }
     $key_exists = array_key_exists($key, $this->cache_sums);
     $expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
     if (!$key_exists) {
         // Try INSERT temporarily ignoring "duplicate key" errors
         $this->db->set_option('ignore_key_errors', true);
         $result = $this->db->query("INSERT INTO {$this->table} (`expires`, `cache_key`, `data`)" . " VALUES ({$expires}, ?, ?)", $db_key, $data);
         $this->db->set_option('ignore_key_errors', false);
     }
     // otherwise try UPDATE
     if (!isset($result) || !($count = $this->db->affected_rows($result))) {
         $result = $this->db->query("UPDATE {$this->table} SET `expires` = {$expires}, `data` = ?" . " WHERE `cache_key` = ?", $data, $db_key);
         $count = $this->db->affected_rows($result);
     }
     return $count > 0;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:53,代码来源:rcube_cache_shared.php

示例7: add_thread_row

 /**
  * Saves thread data into database
  */
 private function add_thread_row($mailbox, $data, $mbox_data = array(), $exists = false)
 {
     $data = array($this->db->encode($data, true), (int) $this->skip_deleted, (int) $mbox_data['UIDVALIDITY'], (int) $mbox_data['UIDNEXT']);
     $data = implode('@', $data);
     $expires = $this->ttl ? $this->db->now($this->ttl) : 'NULL';
     if ($exists) {
         $res = $this->db->query("UPDATE {$this->thread_table}" . " SET `data` = ?, `expires` = {$expires}" . " WHERE `user_id` = ?" . " AND `mailbox` = ?", $data, $this->userid, $mailbox);
         if ($this->db->affected_rows($res)) {
             return;
         }
     }
     $this->db->set_option('ignore_key_errors', true);
     $res = $this->db->query("INSERT INTO {$this->thread_table}" . " (`user_id`, `mailbox`, `expires`, `data`)" . " VALUES (?, ?, {$expires}, ?)", $this->userid, $mailbox, $data);
     // race-condition, insert failed so try update (#1489146)
     // thanks to ignore_key_errors "duplicate row" errors will be ignored
     if (!$exists && !$res && !$this->db->is_error($res)) {
         $this->db->query("UPDATE {$this->thread_table}" . " SET `expires` = {$expires}, `data` = ?" . " WHERE `user_id` = ?" . " AND `mailbox` = ?", $data, $this->userid, $mailbox);
     }
     $this->db->set_option('ignore_key_errors', false);
 }
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:23,代码来源:rcube_imap_cache.php


注:本文中的rcube_db::affected_rows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。