diff options
-rw-r--r-- | idiorm.php | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -947,6 +947,28 @@ } /** + * Add a RAW JOIN source to the query + */ + public function raw_join($table, $constraint, $table_alias=null) { + // Add table alias if present + if (!is_null($table_alias)) { + $table_alias = $this->_quote_identifier($table_alias); + $table .= " {$table_alias}"; + } + + // Build the constraint + if (is_array($constraint)) { + list($first_column, $operator, $second_column) = $constraint; + $first_column = $this->_quote_identifier($first_column); + $second_column = $this->_quote_identifier($second_column); + $constraint = "{$first_column} {$operator} {$second_column}"; + } + + $this->_join_sources[] = "{$table} ON {$constraint}"; + return $this; + } + + /** * Add a simple JOIN source to the query */ public function join($table, $constraint, $table_alias=null) { |