selectAll() public static method

Method referring to the fetchAll(PDO::FETCH_BOTH)
public static selectAll ( 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 both by the name as the column number
Esempio 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));
 }
Esempio n. 2
0
 /**
  * All Selects
  * 
  * */
 public function allSelects()
 {
     // SQL query
     $sql = self::sql();
     // Executes the SQL and stores the result
     $result = PDO4You::select($sql);
     $result_num = PDO4You::selectNum($sql);
     $result_obj = PDO4You::selectObj($sql);
     $result_all = PDO4You::selectAll($sql);
     echo '<div class="code title">Demo with the method PDO4You::select()</div>';
     echo '<div class="code debug">PDO4You::select(' . $this->getQuery($sql) . '); ' . $this->getResult($result) . '</div>';
     echo '<div class="code title">Demo with the method PDO4You::selectNum()</div>';
     echo '<div class="code debug">PDO4You::selectNum(' . $this->getQuery($sql) . '); ' . $this->getResult($result_num) . '</div>';
     echo '<div class="code title">Demo with the method PDO4You::selectObj()</div>';
     echo '<div class="code debug">PDO4You::selectObj(' . $this->getQuery($sql) . '); ' . $this->getResult($result_obj) . '</div>';
     echo '<div class="code title">Demo with the method PDO4You::selectAll()</div>';
     echo '<div class="code debug">PDO4You::selectAll(' . $this->getQuery($sql) . '); ' . $this->getResult($result_all) . '</div>';
 }