Horde_Db_Adapter::selectOne PHP 메소드

selectOne() 공개 메소드

Returns a record hash with the column names as keys and column values as values.
public selectOne ( string $sql, mixed $arg1 = null, string $arg2 = null ) : array
$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.
리턴 array
    public function selectOne($sql, $arg1 = null, $arg2 = null);

Usage Example

예제 #1
0
 /**
  * Finds out if a username and password is valid.
  *
  * @param string $user     The username to check.
  * @param string $oldpass  An old password to check.
  *
  * @throws Passwd_Exception
  */
 protected function _lookup($user, $oldpass)
 {
     /* Only split up username if domain is set in backend configuration. */
     if (!empty($this->_params['domain'])) {
         list($name, $domain) = explode('@', $user);
     } else {
         $name = $user;
     }
     /* Build the SQL query. */
     $sql = 'SELECT ' . $this->_params['passwd'] . ' FROM ' . $this->_params['table'] . ' WHERE ' . $this->_params['name'] . ' = ?';
     $values = array($name);
     if ($this->_params['domain']) {
         $sql .= ' AND ' . $this->_params['domain'] . ' = ?';
         $values[] = $domain;
     }
     /* Execute the query. */
     try {
         $result = $this->_db->selectOne($sql, $values);
     } catch (Horde_Db_Exception $e) {
         throw new Passwd_Exception($e);
     }
     if (!is_array($result)) {
         throw new Passwd_Exception(_("User not found"));
     }
     /* Check the passwords match. */
     $this->_comparePasswords($result[$this->_params['passwd']], $oldpass);
 }
All Usage Examples Of Horde_Db_Adapter::selectOne