| Conditions | 8 |
| Paths | 8 |
| Total Lines | 36 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function getResult() |
||
| 34 | { |
||
| 35 | if ($this->map->referenceModel->row instanceof Sql\DataObjects\Result\Row) { |
||
|
|
|||
| 36 | |||
| 37 | $criteria = $this->map->referenceModel->row->offsetGet($this->map->referenceModel->primaryKey); |
||
| 38 | $conditions = [$this->map->relationForeignKey => $criteria]; |
||
| 39 | |||
| 40 | if ($this->map->relationModel instanceof Sql\Model) { |
||
| 41 | $result = $this->map->relationModel->qb |
||
| 42 | ->from($this->map->relationTable) |
||
| 43 | ->getWhere($conditions, 1); |
||
| 44 | |||
| 45 | if ($result instanceof Result) { |
||
| 46 | if ($result->count() > 0) { |
||
| 47 | $this->map->relationModel->result = new Sql\DataObjects\Result($result, |
||
| 48 | $this->map->relationModel); |
||
| 49 | |||
| 50 | return $this->map->relationModel->row = $this->map->relationModel->result->first(); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } elseif ( ! empty($this->map->relationTable)) { |
||
| 54 | $result = $this->map->referenceModel->qb |
||
| 55 | ->from($this->map->relationTable) |
||
| 56 | ->getWhere($conditions, 1); |
||
| 57 | |||
| 58 | if ($result instanceof Result) { |
||
| 59 | if ($result->count() > 0) { |
||
| 60 | $result = new Sql\DataObjects\Result($result, $this->map->referenceModel); |
||
| 61 | |||
| 62 | return $result->first(); |
||
| 63 | } |
||
| 64 | } |
||
| 65 | } |
||
| 66 | } |
||
| 67 | |||
| 68 | return false; |
||
| 69 | } |
||
| 70 | } |