addQuery() 공개 정적인 메소드

Add query to log
public static addQuery ( $adapter, mixed $query, mixed $data = null )
$query mixed Query run
$data mixed Data used in query - usually array, but can be scalar or null
예제 #1
0
 /**
  * Drop a database table
  * Destructive and dangerous - drops entire table and all data
  * Will throw errors if user does not have proper permissions
  */
 public function dropDatabase($database)
 {
     $sql = "DROP DATABASE " . $database;
     // Add query to log
     \Spot\Log::addQuery($this, $sql);
     return $this->connection()->exec($sql);
 }
예제 #2
0
파일: Sqlite.php 프로젝트: vlucas/spot
 /**
  * Truncate a database table
  * Should delete all rows and reset serial/auto_increment keys to 0
  */
 public function truncateDatasource($datasource)
 {
     $sql = "DELETE FROM " . $datasource;
     // Add query to log
     \Spot\Log::addQuery($this, $sql);
     try {
         return $this->connection()->exec($sql);
     } catch (\PDOException $e) {
         // Table does not exist
         if ($e->getCode() == "42S02") {
             throw new \Spot\Exception_Datasource_Missing("Table or datasource '" . $datasource . "' does not exist");
         }
         // Re-throw exception
         throw $e;
     }
 }