exec() public method

See also: Adapter::exec
public exec ( $sql, $bindings = [], $noevent = FALSE )
Exemplo n.º 1
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     $this->adapter->exec('SET CONSTRAINTS ALL DEFERRED');
     foreach ($this->getTables() as $t) {
         $t = $this->esc($t);
         $this->adapter->exec("DROP TABLE IF EXISTS {$t} CASCADE ");
     }
     $this->adapter->exec('SET CONSTRAINTS ALL IMMEDIATE');
 }
Exemplo n.º 2
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     foreach ($this->getTables() as $t) {
         foreach ($this->getKeyMapForType($t) as $k) {
             $this->adapter->exec("ALTER TABLE \"{$t}\" DROP FOREIGN KEY \"{$k['name']}\"");
         }
     }
     foreach ($this->getTables() as $t) {
         $this->adapter->exec("DROP TABLE \"{$t}\"");
     }
 }
Exemplo n.º 3
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     $this->adapter->exec('SET CONSTRAINTS ALL DEFERRED');
     foreach ($this->getTables() as $t) {
         $t = $this->esc($t);
         //Some plugins (PostGIS have unremovable tables/views), avoid exceptions.
         try {
             $this->adapter->exec("DROP TABLE IF EXISTS {$t} CASCADE ");
         } catch (\Exception $e) {
         }
     }
     $this->adapter->exec('SET CONSTRAINTS ALL IMMEDIATE');
 }
Exemplo n.º 4
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     foreach ($this->getTables() as $t) {
         try {
             $foreignKeys = $this->adapter->getAssoc("SELECT\n\t\t\t\t    'ALTER TABLE ' +  OBJECT_SCHEMA_NAME(parent_object_id) +\n\t\t\t\t    '.[' + OBJECT_NAME(parent_object_id) +\n\t\t\t\t    '] DROP CONSTRAINT ' + name\n\t\t\t\tFROM sys.foreign_keys\n\t\t\t\tWHERE referenced_object_id = object_id('{$t}')");
             if (count($foreignKeys)) {
                 foreach ($foreignKeys as $sql) {
                     $this->adapter->exec($sql);
                 }
             }
             $this->adapter->exec("IF OBJECT_ID('[{$t}]', 'U') IS NOT NULL DROP TABLE [{$t}];");
         } catch (SQLException $e) {
         }
     }
 }
Exemplo n.º 5
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     $this->adapter->exec('SET FOREIGN_KEY_CHECKS = 0;');
     foreach ($this->getTables() as $t) {
         try {
             $this->adapter->exec("DROP TABLE IF EXISTS `{$t}`");
         } catch (\Exception $e) {
         }
         try {
             $this->adapter->exec("DROP VIEW IF EXISTS `{$t}`");
         } catch (\Exception $e) {
         }
     }
     $this->adapter->exec('SET FOREIGN_KEY_CHECKS = 1;');
 }
Exemplo n.º 6
0
 /**
  * @see QueryWriter::wipeAll
  */
 public function wipeAll()
 {
     $this->adapter->exec('PRAGMA foreign_keys = 0 ');
     foreach ($this->getTables() as $t) {
         try {
             $this->adapter->exec("DROP TABLE IF EXISTS `{$t}`");
         } catch (\Exception $e) {
         }
         try {
             $this->adapter->exec("DROP TABLE IF EXISTS `{$t}`");
         } catch (\Exception $e) {
         }
     }
     $this->adapter->exec('PRAGMA foreign_keys = 1 ');
 }
Exemplo n.º 7
0
 /**
  * @see QueryWriter::wipe
  */
 public function wipe($type)
 {
     $table = $this->esc($type);
     $this->adapter->exec("TRUNCATE {$table} ");
 }