selectValue() public method

Returns a single value from a record
public selectValue ( string $sql, mixed $arg1 = null, string $arg2 = null ) : string
$sql string SQL statement.
$arg1 mixed Either an array of bound parameters or a query name.
$arg2 string If $arg1 contains bound parameters, the query name.
return string
コード例 #1
0
ファイル: Horde.php プロジェクト: raz0rsdge/horde
 /**
  * Returns a timestamp stored in the map for a given Server ID.
  *
  * The timestamp is the timestamp of the last change to this server ID
  * that was done inside a sync session (as a result of a change received
  * by the server). It's important to distinguish changes in the backend a)
  * made by the user during normal operation and b) changes made by SyncML
  * to reflect client updates.  When the server is sending its changes it
  * is only allowed to send type a). However the history feature in the
  * backend my not know if a change is of type a) or type b). So the
  * timestamp is used to differentiate between the two.
  *
  * @param string $databaseURI  URI of database to sync. Like calendar,
  *                             tasks, contacts or notes. May include
  *                             optional parameters:
  *                             tasks?options=ignorecompleted.
  * @param string $suid         The server ID.
  *
  * @return mixed  The previously stored timestamp or false if no entry is
  *                found.
  */
 protected function _getChangeTS($databaseURI, $suid)
 {
     $database = $this->normalize($databaseURI);
     $query = 'SELECT syncml_timestamp FROM horde_syncml_map ' . 'WHERE syncml_syncpartner = ? AND syncml_db = ? AND ' . 'syncml_uid = ? AND syncml_suid = ?';
     $values = array($this->_syncDeviceID, $database, $this->_user, $suid);
     return $this->_db->selectValue($query, $values);
 }
コード例 #2
0
ファイル: Sql.php プロジェクト: jubinpatel/horde
 /**
  * Returns an attribute name.
  *
  * @param integer $attribute_id  An attribute ID.
  *
  * @return string  The attribute name.
  * @throws Whups_Exception
  */
 public function getAttributeName($attribute_id)
 {
     try {
         $name = $this->_db->selectValue('SELECT attribute_name FROM whups_attributes_desc ' . 'WHERE attribute_id = ?', array((int) $attribute_id));
     } catch (Horde_Db_Exception $e) {
         throw new Whups_Exception($e);
     }
     return $this->_fromBackend($name);
 }
コード例 #3
0
ファイル: Sql.php プロジェクト: horde/horde
 /**
  * Gets the latest released story from a given internal channel
  *
  * @param int $channel_id  The channel id.
  *
  * @return int  The story id.
  * @throws Jonah_Exception
  * @throws Horde_Exception_NotFound
  */
 public function getLatestStoryId($channel_id)
 {
     $sql = 'SELECT story_id FROM jonah_stories' . ' WHERE channel_id = ? AND story_published <= ?' . ' ORDER BY story_updated DESC';
     Horde::log('SQL Query by Jonah_Driver_sql::getLatestStoryId(): ' . $sql, 'DEBUG');
     try {
         $result = $this->_db->selectValue($sql, array((int) $channel_id, time()));
     } catch (Horde_Db_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Jonah_Exception($e);
     }
     if (empty($result)) {
         return Horde_Exception_NotFound(sprintf(_("Channel \"%s\" not found."), $channel_id));
     }
     return $result;
 }