From 6ffc8f63c8a9a76c5323a4013382a61eb4d7031a Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Aug 2017 16:38:24 +0300 Subject: Optimize the join() type regexp and remove the extra leading space when no special join-type is used --- system/database/DB_query_builder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/database') diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index d35d84d6d..3ff94be8e 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -525,8 +525,8 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function join($table, $cond, $type = '', $escape = NULL) { - $type = strtoupper(trim($type)); - preg_match('#^(NATURAL(?=\s|$)\s*)?((LEFT|RIGHT)(?=\s|$))?\s*(INNER|OUTER)?$#', $type) OR $type = ''; + $type = trim(strtoupper($type).' JOIN'); + preg_match('#^(NATURAL\s+)?((LEFT|RIGHT)\s+)?((INNER|OUTER)\s+)?JOIN$#', $type) OR $type = 'JOIN'; // Extract any aliases that might exist. We use this information // in the protect_identifiers to know whether to add a table prefix @@ -587,7 +587,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // Assemble the JOIN statement - $this->qb_join[] = $join = $type.' JOIN '.$table.$cond; + $this->qb_join[] = $join = $type.' '.$table.$cond; if ($this->qb_caching === TRUE) { -- cgit v1.2.3-24-g4f1b