diff options
author | Igor Moiseev <[email protected]> | 2013-10-24 00:56:22 +0200 |
---|---|---|
committer | Simon Holywell <[email protected]> | 2014-04-26 13:45:46 +0100 |
commit | de29638b4891c47b6293a52b76d146675fbcd012 (patch) | |
tree | 40eab82d3ea6673b9ba203fc8adcc9f955391c04 /idiorm.php | |
parent | 73f00fd6966570357196e0da51cf933490d230c3 (diff) |
Add a RAW JOIN source to the query
Diffstat (limited to 'idiorm.php')
-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) { |