diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-02-25 08:19:49 +0100 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-07-21 23:17:36 +0200 |
commit | cd98ff1eafabf5b10ff67594b65d979a943afe09 (patch) | |
tree | 9bd51e461cab0d652edcf05e03bbf35065c8e8b0 /lib/db | |
parent | 66a215651badf8472e9922b7591cba3cfe9ce333 (diff) | |
download | nextcloud-server-cd98ff1eafabf5b10ff67594b65d979a943afe09.tar.gz nextcloud-server-cd98ff1eafabf5b10ff67594b65d979a943afe09.zip |
Move db prefix handling to Connection wrapper
Diffstat (limited to 'lib/db')
-rw-r--r-- | lib/db/connection.php | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/db/connection.php b/lib/db/connection.php index 5466609e671..40809330da6 100644 --- a/lib/db/connection.php +++ b/lib/db/connection.php @@ -14,7 +14,6 @@ use Doctrine\Common\EventManager; class Connection extends \Doctrine\DBAL\Connection { protected $table_prefix; - protected $sequence_suffix; protected $adapter; @@ -32,8 +31,12 @@ class Connection extends \Doctrine\DBAL\Connection { if (!isset($params['adapter'])) { throw new Exception('adapter not set'); } + if (!isset($params['table_prefix'])) { + throw new Exception('table_prefix not set'); + } parent::__construct($params, $driver, $config, $eventManager); $this->adapter = new $params['adapter']($this); + $this->table_prefix = $params['table_prefix']; } /** @@ -43,7 +46,7 @@ class Connection extends \Doctrine\DBAL\Connection { * @return \Doctrine\DBAL\Driver\Statement The prepared statement. */ public function prepare( $statement, $limit=null, $offset=null ) { - // TODO: prefix + $statement = $this->replaceTablePrefix($statement); // TODO: limit & offset // TODO: prepared statement cache return parent::prepare($statement); @@ -85,4 +88,9 @@ class Connection extends \Doctrine\DBAL\Connection { // TODO: prefix return parent::executeUpdate($query, $params, $types); } + + // internal use + public function replaceTablePrefix($statement) { + return str_replace( '*PREFIX*', $this->table_prefix, $statement ); + } } |