Esempio n. 1
0
 private function getFieldsListFromDatabase()
 {
     $Connection = Connection::getConnection();
     $request = $Connection->prepare("SELECT TABLE_NAME, COLUMN_NAME, DATA_TYPE FROM `information_schema`.`COLUMNS` WHERE TABLE_SCHEMA LIKE ? AND TABLE_NAME LIKE ?");
     $request->execute([Connection::getDatabaseName(), $this->_tableName]);
     $array = [];
     foreach ($request->fetchAll() as $k => $v) {
         $array[] = $v['COLUMN_NAME'];
     }
     return $array;
 }
Esempio n. 2
0
 public static function query($sql, $params = [])
 {
     $Connection = Connection::getConnection();
     $request = $Connection->prepare($sql);
     if ($request->execute($params)) {
         $Logger = new Logger(dirname(dirname(__DIR__)) . '/access.log');
         $Logger->add($sql);
     } else {
         $errorInfo = $request->errorInfo();
         $Logger = new Logger(dirname(dirname(__DIR__)) . '/error.log');
         $Logger->add($sql . ' | ' . $errorInfo[2]);
     }
     return $request->fetchAll();
 }