예제 #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;
 }
예제 #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();
 }
예제 #3
0
파일: Base.php 프로젝트: gigorok/php-orm
 /**
  * Establish connection
  *
  * @param $connection Connection connection params
  */
 public static function establishConnection(Connection $connection)
 {
     static::$connection = $connection->getInstance();
 }