/**
  * @param $sql string
  * // todo: add fetch types
  * @param string $fetch_type string [assoc, object, ...]
  * @return array
  */
 public function query($sql, $fetch_type = 'assoc')
 {
     // todo: check sql string
     $this->mysqli->query($sql);
     $rows = array();
     $result = $this->mysqli->query($sql);
     if (!$result) {
         $this->loger->addLog(LOG_ERR, mysqli_error($this->mysqli));
         // todo: goto html output
         die;
     }
     switch ($fetch_type) {
         default:
         case 'assoc':
             while ($row = $result->fetch_assoc()) {
                 $rows[] = $row;
             }
             break;
         case 'object':
             while ($row = $result->fetch_object()) {
                 $rows[] = $row;
             }
             break;
     }
     return $rows;
 }
Exemple #2
0
 public function __construct(ILoger $loger)
 {
     $loger->addLog('123123', 'qwe');
 }