| @@ 41-53 (lines=13) @@ | ||
| 38 | $this->context = $context; |
|
| 39 | } |
|
| 40 | ||
| 41 | public function prepareQuery($data) { |
|
| 42 | // @todo throw an exception when the data doesn't have the local key |
|
| 43 | $query = $this->getQuery(); |
|
| 44 | if ($this->queryPrepared) { |
|
| 45 | $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]); |
|
| 46 | } else { |
|
| 47 | $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table']) |
|
| 48 | ->addFilter($this->options['foreign_key'], $data[$this->options['local_key']]); |
|
| 49 | $this->queryPrepared = true; |
|
| 50 | } |
|
| 51 | return $query; |
|
| 52 | } |
|
| 53 | ||
| 54 | public function runSetup() { |
|
| 55 | if ($this->options['foreign_key'] == null) { |
|
| 56 | $this->options['foreign_key'] = Text::singularize($this->setupTable) . '_id'; |
|
| @@ 36-48 (lines=13) @@ | ||
| 33 | ||
| 34 | protected $type = self::BELONGS_TO; |
|
| 35 | ||
| 36 | public function prepareQuery($data) { |
|
| 37 | // @todo throw an exception when the data doesn't have the local key |
|
| 38 | $query = $this->getQuery(); |
|
| 39 | if($this->queryPrepared){ |
|
| 40 | $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]); |
|
| 41 | } else { |
|
| 42 | $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table']) |
|
| 43 | ->addFilter($this->options['foreign_key'], $data[$this->options['local_key']]) |
|
| 44 | ->setFirstOnly(true); |
|
| 45 | $this->queryPrepared = true; |
|
| 46 | } |
|
| 47 | return $query; |
|
| 48 | } |
|
| 49 | ||
| 50 | public function runSetup() { |
|
| 51 | $model = ORMContext::getInstance()->getModelFactory()->createModel($this->options['model'], self::BELONGS_TO); |
|