Horde_Db_Adapter::selectValues PHP Method

selectValues() public method

Returns an array of the values of the first column in a select: selectValues("SELECT id FROM companies LIMIT 3") => [1,2,3]
public selectValues ( 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.
return array
    public function selectValues($sql, $arg1 = null, $arg2 = null);

Usage Example

Example #1
0
 /**
  * Removes a permission from the permissions system permanently.
  *
  * @param Horde_Perms_Permission_Sql $perm  The permission to
  *                                                remove.
  * @param boolean $force                          Force to remove every
  *                                                child.
  *
  * @return boolean  True if permission was deleted.
  * @throws Horde_Perms_Exception
  */
 public function removePermission(Horde_Perms_Permission $perm, $force = false)
 {
     $name = $perm->getName();
     $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $name);
     $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $name);
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name = ?';
     try {
         $result = $this->_db->delete($query, array($name));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Perms_Exception($e);
     }
     if (!$force) {
         return (bool) $result;
     }
     /* Need to expire cache for all sub-permissions. */
     try {
         $sub = $this->_db->selectValues('SELECT perm_name FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?', array($name . ':%'));
         foreach ($sub as $val) {
             $this->_cache->expire('perm_sql_' . $this->_cacheVersion . $val);
             $this->_cache->expire('perm_sql_exists_' . $this->_cacheVersion . $val);
         }
     } catch (Horde_Db_Exception $e) {
     }
     $query = 'DELETE FROM ' . $this->_params['table'] . ' WHERE perm_name LIKE ?';
     try {
         return (bool) $this->_db->delete($query, array($name . ':%'));
     } catch (Horde_Db_Exception $e) {
         throw new Horde_Perms_Exception($e);
     }
 }
All Usage Examples Of Horde_Db_Adapter::selectValues