addQuery() public static method

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
Beispiel #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);
 }
Beispiel #2
0
 /**
  * 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;
     }
 }