function __construct(&$source, $dest, $options = null) { parent::__construct($source, $dest, $options); if (!isset($options['foreign_key'])) { $this->foreign_key = ActiveRecordInflector::foreign_key($this->dest_class); } }
function __construct($source, $dest, $options = null) { $this->source_class = get_class($source); if (isset($options['class_name'])) { $this->dest_class = $options['class_name']; } else { $this->dest_class = ActiveRecordInflector::classify($dest); } if (isset($options['foreign_key'])) { $this->foreign_key = $options['foreign_key']; } else { $this->foreign_key = ActiveRecordInflector::foreign_key($this->source_class); } $this->options = $options; }
function __construct(&$source, $dest, $options = null) { parent::__construct($source, $dest, $options); $this->foreign_key = ActiveRecordInflector::foreign_key($this->source_class); }
function join() { $dest_table = ActiveRecordInflector::tableize($this->dest_class); $source_table = ActiveRecordInflector::tableize($this->source_class); $source_inst = new $this->source_class(); $dest_inst = new $this->dest_class(); $columns = $dest_inst->get_columns(); if (!isset($this->options['through']) || !$this->options['through']) { $join = "LEFT OUTER JOIN {$dest_table} ON " . "{$dest_table}.{$this->foreign_key} = {$source_table}." . $source_inst->get_primary_key(); } else { $join = "LEFT OUTER JOIN {$this->options['through']} ON " . "{$this->options['through']}.{$this->foreign_key} = {$source_table}." . $source_inst->get_primary_key() . " " . "LEFT OUTER JOIN {$dest_table} ON " . "{$dest_table}." . $dest_inst->get_primary_key() . " = {$this->options['through']}." . ActiveRecordInflector::foreign_key($this->dest_class); } return array(array($dest_table => $columns), $join); }