diff options
author | Andrey Andreev <narf@devilix.net> | 2017-08-29 14:34:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-29 14:34:07 +0200 |
commit | 941b614f6f5dfb7201954a6719615475b8aee194 (patch) | |
tree | 15916f7591d9968f0a04da473bb19f9ae5411287 /system/database/DB_query_builder.php | |
parent | cbe27d76f0aaba7b40f4b23904e4258964bdc50c (diff) | |
parent | 8958af6bf463ef958d798d22b4e0be68b721102d (diff) |
Merge pull request #5242 from jvyyuie/natural
add NATURAL JOIN types
Diffstat (limited to 'system/database/DB_query_builder.php')
-rw-r--r-- | system/database/DB_query_builder.php | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index 102ff4ac0..9564e8870 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -525,17 +525,24 @@ abstract class CI_DB_query_builder extends CI_DB_driver { */ public function join($table, $cond, $type = '', $escape = NULL) { + $natural_join = FALSE; + if ($type !== '') { $type = strtoupper(trim($type)); - if ( ! in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE)) + if (in_array($type, array('LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER'), TRUE)) { - $type = ''; + $type .= ' '; } - else + elseif (in_array($type, array('NATURAL', 'NATURAL LEFT', 'NATURAL RIGHT', 'NATURAL LEFT OUTER', 'NATURAL RIGHT OUTER'), TRUE)) { $type .= ' '; + $natural_join = TRUE; + } + else + { + $type = ''; } } @@ -594,7 +601,14 @@ abstract class CI_DB_query_builder extends CI_DB_driver { } // Assemble the JOIN statement - $this->qb_join[] = $join = $type.'JOIN '.$table.$cond; + if ($natural_join === FALSE) + { + $this->qb_join[] = $join = $type.'JOIN '.$table.$cond; + } + else + { + $this->qb_join[] = $join = $type.'JOIN '.$table; + } if ($this->qb_caching === TRUE) { |