Author: Mike Naberezny (mike@maintainable.com)
Author: Derek DeVries (derek@maintainable.com)
Author: Chuck Hagenbuch (chuck@horde.org)
Inheritance: implements Horde_Db_Adapter
Beispiel #1
0
 /**
  * Erases all mapping entries for one combination of user, device ID.
  *
  * This is used during SlowSync so that we really sync everything properly
  * and no old mapping entries remain.
  *
  * @param string $databaseURI  URI of database to sync. Like calendar,
  *                             tasks, contacts or notes. May include
  *                             optional parameters:
  *                             tasks?options=ignorecompleted.
  */
 public function eraseMap($databaseURI)
 {
     $database = $this->normalize($databaseURI);
     $query = 'DELETE FROM horde_syncml_map ' . 'WHERE syncml_syncpartner = ? AND syncml_db = ? AND ' . 'syncml_uid = ?';
     $values = array($this->_syncDeviceID, $database, $this->_user);
     $this->_db->delete($query, $values);
 }
Beispiel #2
0
 /**
  * Quotes the column value to help prevent SQL injection attacks.
  *
  * This method makes educated guesses on the scalar type based on the
  * passed value. Make sure to correctly cast the value and/or pass the
  * $column parameter to get the best results.
  *
  * @param mixed $value    The scalar value to quote, a Horde_Db_Value,
  *                        Horde_Date, or DateTime instance, or an object
  *                        implementing quotedId().
  * @param object $column  An object implementing getType().
  *
  * @return string  The correctly quoted value.
  */
 public function quote($value, $column = null)
 {
     if (is_object($value) && is_callable(array($value, 'quotedId'))) {
         return $value->quotedId();
     }
     if ($value instanceof Horde_Db_Value) {
         return $value->quote($this->_adapter);
     }
     $type = isset($column) ? $column->getType() : null;
     if (is_null($value)) {
         return 'NULL';
     } elseif ($value === true) {
         return $type == 'integer' ? '1' : $this->quoteTrue();
     } elseif ($value === false) {
         return $type == 'integer' ? '0' : $this->quoteFalse();
     } elseif (is_float($value)) {
         return sprintf('%F', $value);
     } elseif (is_int($value)) {
         return $value;
     } elseif ($value instanceof DateTime || $value instanceof Horde_Date) {
         return $this->_adapter->quoteString($type == 'integer' ? $value->format('U') : $value->format('Y-m-d H:i:s'));
     } elseif ($type == 'integer') {
         return (int) $value;
     } elseif ($type == 'float') {
         return sprintf('%F', $value);
     } else {
         return $this->_adapter->quoteString($value);
     }
 }
Beispiel #3
0
 /**
  */
 public function deleteStory($channel_id, $story_id)
 {
     $sql = 'DELETE FROM jonah_stories' . ' WHERE channel_id = ? AND story_id = ?';
     $values = array((int) $channel_id, (int) $story_id);
     Horde::log('SQL Query by Jonah_Driver_sql::deleteStory(): ' . $sql, 'DEBUG');
     try {
         $this->_db->delete($sql, $values);
     } catch (Horde_Db_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Jonah_Exception($e);
     }
 }
Beispiel #4
0
 /**
  * Return a station object matching $code.
  *
  * @param string $code  The ICAO station identifier.
  *
  * @return Horde_Service_Weather_Station  The station object.
  * @throws  Horde_Service_Weather_Exception
  * @throws  Horde_Exception_NotFound
  */
 protected function _getStation($code)
 {
     if (empty($this->_db)) {
         return new Horde_Service_Weather_Station(array('code' => $code, 'name' => $code));
     }
     $sql = 'SELECT icao, name, country, latitude, longitude from ' . $this->_tableName . ' WHERE icao = ?';
     try {
         $result = $this->_db->selectOne($sql, array($code));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Service_Weather_Exception($e);
     }
     if (empty($result)) {
         throw new Horde_Exception_NotFound();
     }
     return new Horde_Service_Weather_Station(array('name' => $result['name'], 'code' => $code, 'country_name' => $result['country'], 'lat' => $result['latitude'], 'lon' => $result['lon']));
 }
Beispiel #5
0
 protected function _fromBackend($value)
 {
     return Horde_String::convertCharset($value, $this->_db->getOption('charset'), 'UTF-8');
 }
Beispiel #6
0
 /**
  * Disconnect from db
  */
 public function disconnect()
 {
     if ($this->_connection) {
         oci_close($this->_connection);
     }
     parent::disconnect();
 }
Beispiel #7
0
 /**
  * Disconnect from db
  */
 public function disconnect()
 {
     if ($this->_connection) {
         $this->_connection->close();
     }
     parent::disconnect();
 }