summaryrefslogtreecommitdiffstats
path: root/system/database/DB_query_builder.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/DB_query_builder.php')
-rw-r--r--system/database/DB_query_builder.php22
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)
{