Skip to content

Commit

Permalink
allow to use sqlite's native alter method
Browse files Browse the repository at this point in the history
  • Loading branch information
splitbrain committed Dec 17, 2015
1 parent 6c7ee3f commit 8b04838
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions classes/adapter.php
Expand Up @@ -10,6 +10,7 @@ abstract class helper_plugin_sqlite_adapter {
protected $dbfile;
protected $db = null;
protected $data = array();
protected $nativealter = false;

/**
* return name of adapter
Expand All @@ -18,6 +19,15 @@ abstract class helper_plugin_sqlite_adapter {
*/
public abstract function getName();

/**
* Should the nativ ALTER TABLE implementation be used instead of workaround?
*
* @param bool $set
*/
public function setUseNativeAlter($set) {
$this->nativealter = $set;
}

/**
* The file extension used by the adapter
*
Expand Down Expand Up @@ -131,9 +141,11 @@ public function query($args) {
if(!$sql) return false;

// intercept ALTER TABLE statements
$match = null;
if(preg_match('/^ALTER\s+TABLE\s+([\w\.]+)\s+(.*)/i', $sql, $match)) {
return $this->_altertable($match[1], $match[2]);
if(!$this->nativealter) {
$match = null;
if(preg_match('/^ALTER\s+TABLE\s+([\w\.]+)\s+(.*)/i', $sql, $match)) {
return $this->_altertable($match[1], $match[2]);
}
}

// execute query
Expand Down

0 comments on commit 8b04838

Please sign in to comment.