/** * Creates a map entry to map between server and client IDs. * * If an entry already exists, it is overwritten. * * @param string $databaseURI URI of database to sync. Like calendar, * tasks, contacts or notes. May include * optional parameters: * tasks?options=ignorecompleted. * @param string $cuid Client ID of the entry. * @param string $suid Server ID of the entry. * @param integer $timestamp Optional timestamp. This can be used to * 'tag' changes made in the backend during the * sync process. This allows to identify these, * and ensure that these changes are not * replicated back to the client (and thus * duplicated). See key concept "Changes and * timestamps". */ public function createUidMap($databaseURI, $cuid, $suid, $timestamp = 0) { $database = $this->normalize($databaseURI); $values = array($suid, (int) $timestamp, $this->_syncDeviceID, $database, $this->_user, $cuid); // Check if entry exists. If not insert, otherwise update. if (!$this->_getSuid($databaseURI, $cuid)) { $query = 'INSERT INTO horde_syncml_map ' . '(syncml_suid, syncml_timestamp, syncml_syncpartner, ' . 'syncml_db, syncml_uid, syncml_cuid) ' . 'VALUES (?, ?, ?, ?, ?, ?)'; $this->_db->insert($query, $values); } else { $query = 'UPDATE horde_syncml_map ' . 'SET syncml_suid = ?, syncml_timestamp = ? ' . 'WHERE syncml_syncpartner = ? AND syncml_db = ? AND ' . 'syncml_uid = ? AND syncml_cuid = ?'; $this->_db->update($query, $values); } }
/** * Adds a missing permalink to a story. * * @param array $story A story hash. * * @throws Jonah_Exception */ protected function _addPermalink(&$story) { $channel = $this->getChannel($story['channel_id']); $sql = 'UPDATE jonah_stories SET story_permalink = ? WHERE story_id = ?'; $link = $this->getStoryLink($channel, $story); Horde::log('SQL Query by Jonah_Driver_sql::_addPermalink(): ' . $sql, 'DEBUG'); try { $this->_db->update($sql, array($link, $story['id'])); } catch (Horde_Db_Exception $e) { throw new Jonah_Exception($result); } $story['permalink'] = $link; }
/** * Create a new transaction ID. * * @param string $creator A transaction creator. * @param string $creator_email The transaction creator's email address. * * @return integer A transaction ID. * @throws Whups_Exception */ public function newTransaction($creator, $creator_email = null) { $insert = 'INSERT INTO whups_transactions ' . '(transaction_timestamp, transaction_user_id) VALUES(?, ?)'; $this->_db->beginDbTransaction(); try { if ((empty($creator) || $creator < 0) && !empty($creator_email)) { // Need to insert dummy value first so we can get the // transaction ID. $transactionId = $this->_db->insert($insert, array(time(), 'x')); $creator = '-' . $transactionId . '_transaction'; $this->_db->insert('INSERT INTO whups_guests (guest_id, guest_email) ' . 'VALUES (?, ?)', array((string) $creator, $creator_email)); $this->_db->update('UPDATE whups_transactions SET transaction_user_id = ? ' . 'WHERE transaction_id = ?', array($creator, $transactionId)); } else { $transactionId = $this->_db->insert($insert, array(time(), $creator)); } } catch (Horde_Db_Exception $e) { $this->_db->rollbackDbTransaction(); throw new Whups_Exception($e); } $this->_db->commitDbTransaction(); return $transactionId; }