Horde_Db_Adapter::selectAll PHP Метод

selectAll() публичный Метод

Returns an array of record hashes with the column names as keys and column values as values.
public selectAll ( 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 selectAll($sql, $arg1 = null, $arg2 = null);

Usage Example

Пример #1
0
 /**
  * Ensure that an array of users exist in storage. Create any that don't,
  * return user_ids for all.
  *
  * @param array $users  An array of users. Values typed as an integer
  *                        are assumed to already be an user_id.
  *
  * @return array  An array of user_ids.
  */
 public function ensureUsers($users)
 {
     if (!is_array($users)) {
         $users = array($users);
     }
     $userIds = array();
     $userName = array();
     // Anything already typed as an integer is assumed to be a user id.
     foreach ($users as $userIndex => $user) {
         if (is_int($user)) {
             $userIds[$userIndex] = $user;
         } else {
             $userName[$user] = $userIndex;
         }
     }
     // Get the ids for any users that already exist.
     try {
         if (count($userName)) {
             $userName;
             $sql = 'SELECT user_id, user_name FROM ' . $this->_t('users') . ' WHERE user_name IN (' . implode(',', array_map(array($this, 'toDriver'), array_keys($userName))) . ')';
             foreach ($this->_db->selectAll($sql) as $row) {
                 $userIndex = $userName[$row['user_name']];
                 unset($userName[$row['user_name']]);
                 $userIds[$userIndex] = $row['user_id'];
             }
         }
         // Create any users that didn't already exist
         foreach ($userName as $user => $userIndex) {
             $userIds[$userIndex] = $this->_db->insert('INSERT INTO ' . $this->_t('users') . ' (user_name) VALUES (' . $this->toDriver($user) . ')');
         }
     } catch (Horde_Db_Exception $e) {
         throw new Content_Exception($e);
     }
     return $userIds;
 }
All Usage Examples Of Horde_Db_Adapter::selectAll