diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-06-01 11:23:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-06-01 11:23:27 +0000 |
commit | 984f27efc9ea5e579d1394292d8d2bb2f9123055 (patch) | |
tree | e689a13295f076b0563b0943d6f9cd783e13cd9a /includes/database/sqlite | |
parent | 706ce87579e8c29953583a5bfd417aa7e1fbe4b5 (diff) | |
download | brdo-984f27efc9ea5e579d1394292d8d2bb2f9123055.tar.gz brdo-984f27efc9ea5e579d1394292d8d2bb2f9123055.tar.bz2 |
- Patch #106559 by kbahey, catch, DamZ, chx et al: more drupal_lookup_path() optimizations.
Diffstat (limited to 'includes/database/sqlite')
-rw-r--r-- | includes/database/sqlite/database.inc | 15 | ||||
-rw-r--r-- | includes/database/sqlite/schema.inc | 11 |
2 files changed, 23 insertions, 3 deletions
diff --git a/includes/database/sqlite/database.inc b/includes/database/sqlite/database.inc index f4ee1704c..dc79b128d 100644 --- a/includes/database/sqlite/database.inc +++ b/includes/database/sqlite/database.inc @@ -39,6 +39,7 @@ class DatabaseConnection_sqlite extends DatabaseConnection { $this->sqliteCreateFunction('length', 'strlen', 1); $this->sqliteCreateFunction('concat', array($this, 'sqlFunctionConcat')); $this->sqliteCreateFunction('substring', array($this, 'sqlFunctionSubstring'), 3); + $this->sqliteCreateFunction('substring_index', array($this, 'sqlFunctionSubstringIndex'), 3); $this->sqliteCreateFunction('rand', array($this, 'sqlFunctionRand')); } @@ -83,6 +84,20 @@ class DatabaseConnection_sqlite extends DatabaseConnection { } /** + * SQLite compatibility implementation for the SUBSTRING_INDEX() SQL function. + */ + public function sqlFunctionSubstringIndex($string, $delimiter, $count) { + $end = 0; + for ($i = 0; $i < $count; $i++) { + $end = strpos($string, $delimiter, $end + 1); + if ($end === FALSE) { + $end = strlen($string); + } + } + return substr($string, 0, $end); + } + + /** * SQLite compatibility implementation for the RAND() SQL function. */ public function sqlFunctionRand($seed = NULL) { diff --git a/includes/database/sqlite/schema.inc b/includes/database/sqlite/schema.inc index 834a93037..25c07d6c2 100644 --- a/includes/database/sqlite/schema.inc +++ b/includes/database/sqlite/schema.inc @@ -430,7 +430,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema { */ public function addIndex(&$ret, $table, $name, $fields) { $schema['indexes'][$name] = $fields; - $ret[] = update_sql($this->createIndexSql($table, $schema)); + $statements = $this->createIndexSql($table, $schema); + foreach ($statements as $statement) { + $ret[] = update_sql($statement); + } } /** @@ -461,8 +464,10 @@ class DatabaseSchema_sqlite extends DatabaseSchema { */ public function addUniqueKey(&$ret, $table, $name, $fields) { $schema['unique keys'][$name] = $fields; - $ret[] = update_sql($this->createIndexSql($table, $schema)); - + $statements = $this->createIndexSql($table, $schema); + foreach ($statements as $statement) { + $ret[] = update_sql($statement); + } } /** |