@@ 57-81 (lines=25) @@ | ||
54 | * @param string|null $toScenario |
|
55 | * @return ModelWithId|null |
|
56 | */ |
|
57 | public function findById(int $id, string $toScenario = null) |
|
58 | { |
|
59 | ||
60 | // Check cache |
|
61 | if (!$model = $this->findCacheById($id)) { |
|
62 | ||
63 | // Find record in db |
|
64 | if ($record = $this->findRecordById($id)) { |
|
65 | ||
66 | $model = $this->findByRecord($record, $toScenario); |
|
67 | ||
68 | } else { |
|
69 | ||
70 | $this->_cacheById[$id] = null; |
|
71 | ||
72 | return null; |
|
73 | ||
74 | } |
|
75 | ||
76 | } |
|
77 | ||
78 | return $model; |
|
79 | ||
80 | } |
|
81 | ||
82 | /** |
|
83 | * @param int $id |
|
84 | * @param string|null $toScenario |
@@ 41-68 (lines=28) @@ | ||
38 | * @param string|null $toScenario |
|
39 | * @return BaseObject|null |
|
40 | */ |
|
41 | public function findById(int $id, string $toScenario = null) |
|
42 | { |
|
43 | ||
44 | // Check cache |
|
45 | if (!$object = $this->findCacheById($id)) { |
|
46 | ||
47 | // Find record in db |
|
48 | if ($record = $this->findRecordByCondition( |
|
49 | ['id' => $id] |
|
50 | ) |
|
51 | ) { |
|
52 | ||
53 | // Perhaps in cache |
|
54 | $object = $this->findByRecord($record, $toScenario); |
|
55 | ||
56 | } else { |
|
57 | ||
58 | $this->_cacheById[$id] = null; |
|
59 | ||
60 | return null; |
|
61 | ||
62 | } |
|
63 | ||
64 | } |
|
65 | ||
66 | return $object; |
|
67 | ||
68 | } |
|
69 | ||
70 | /** |
|
71 | * @param int $id |