示例#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();
 }