public function join() { $dest_table = \Inflector::tableize($this->dest_class); $source_table = \Inflector::tableize($this->source_class); $dest_inst = new $this->dest_class(); $columns = $dest_inst->get_columns(); $join = array('table' => $dest_table, 'type' => 'LEFT OUTER', 'on' => array($source_table . '.' . $this->foreign_key, '=', $dest_table . '.' . $dest_inst->get_primary_key())); return array(array($dest_table => $columns), $join); }
public function join() { $dest_table = \Inflector::tableize($this->dest_class); $source_table = \Inflector::tableize($this->source_class); $source_inst = new $this->source_class(); $dest_inst = new $this->dest_class(); $columns = $dest_inst->get_columns(); if (isset($dest_inst->table_name)) { $dest_table = $dest_inst->table_name; } if (!isset($this->options['through']) || !$this->options['through']) { $join = array('table' => $dest_table, 'type' => 'LEFT OUTER', 'on' => array($dest_table . '.' . $this->foreign_key, '=', $source_table . '.' . $source_inst->get_primary_key())); } else { $through_foreign_key = array_key_exists('through_foreign_key', $this->options) ? $this->options['through_foreign_key'] : \Inflector::foreign_key($this->dest_class); $join = array(array('table' => $this->options['through'], 'type' => 'LEFT OUTER', 'on' => array($this->options['through'] . '.' . $this->foreign_key, '=', $source_table . '.' . $source_inst->get_primary_key())), array('table' => $dest_table, 'type' => 'LEFT OUTER', 'on' => array($dest_table . '.' . $dest_inst->get_primary_key(), '=', $this->options['through'] . '.' . $through_foreign_key))); } return array(array($dest_table => $columns), $join); }