Exemplo n.º 1
0
 /**
  * Fetch data from database
  * @param string $query
  * @param bool $replica Allow reading data from db replica
  * @return array
  */
 public function fetch($query, $replica = false)
 {
     $this->connect();
     Debugger::prepareDBLine();
     $result = $this->realFetch($query, $replica);
     Debugger::addDBLine('MySQL', $query);
     $this->queries++;
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Fetch single column
  * @param string $query
  * @param array $parameters
  * @param int $column_number
  * @return array|bool
  */
 public function fetchColumn($query, $parameters = [], $column_number = 0)
 {
     Debugger::prepareDBLine();
     $sth = $this->prepare($query);
     $sth->execute($parameters);
     $data = [];
     while (($row = $sth->fetchColumn($column_number)) !== false) {
         $data[] = $row;
     }
     Debugger::addDBLine('DB', $query);
     return $data;
 }