PDO4You\PDO4You::select PHP Method

select() public static method

Method referring to the fetchAll(PDO::FETCH_ASSOC)
public static select ( string $sql, string $use = null ) : array
$sql string Instruction SQL of query of records
$use string OPTIONAL Name of the database defined as a new connection instance
return array Returns an array indexed by column name
    public static function select($sql, $use = null)
    {
        return self::selectRecords($sql, null, $use);
    }

Usage Example

Exemplo n.º 1
0
 public function testAllTypesSelects()
 {
     // SQL query
     $sql = 'SELECT * FROM users';
     // Executes the SQL and stores the result
     $result = test::select($sql);
     $this->assertEquals(1, self::getNumRows($result));
     // Executes the SQL and stores the result
     $result_num = test::selectNum($sql);
     $this->assertEquals(1, self::getNumRows($result_num));
     // Executes the SQL and stores the result
     $result_obj = test::selectObj($sql);
     $this->assertEquals(1, self::getNumRows($result_obj));
     // Executes the SQL and stores the result
     $result_all = test::selectAll($sql);
     $this->assertEquals(1, self::getNumRows($result_all));
 }
All Usage Examples Of PDO4You\PDO4You::select