當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rcube_db::encode方法代碼示例

本文整理匯總了PHP中rcube_db::encode方法的典型用法代碼示例。如果您正苦於以下問題:PHP rcube_db::encode方法的具體用法?PHP rcube_db::encode怎麽用?PHP rcube_db::encode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rcube_db的用法示例。


在下文中一共展示了rcube_db::encode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: serialize

 /**
  * Serializes data for storing
  */
 private function serialize($data)
 {
     if ($this->type == 'db') {
         return $this->db->encode($data, $this->packed);
     }
     return $this->packed ? serialize($data) : $data;
 }
開發者ID:bbspike,項目名稱:sentora-core,代碼行數:10,代碼來源:rcube_cache.php

示例3: 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);
     if ($exists) {
         $sql_result = $this->db->query("UPDATE " . $this->db->table_name('cache_thread') . " SET data = ?, changed = " . $this->db->now() . " WHERE user_id = ?" . " AND mailbox = ?", $data, $this->userid, $mailbox);
     } else {
         $sql_result = $this->db->query("INSERT INTO " . $this->db->table_name('cache_thread') . " (user_id, mailbox, data, changed)" . " VALUES (?, ?, ?, " . $this->db->now() . ")", $this->userid, $mailbox, $data);
     }
 }
開發者ID:CDN-Sparks,項目名稱:owncloud,代碼行數:13,代碼來源:rcube_imap_cache.php

示例4: 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::encode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。