@@ 258-271 (lines=14) @@ | ||
255 | /** |
|
256 | * @return \yii\db\ActiveQuery |
|
257 | */ |
|
258 | public function getPrev() |
|
259 | { |
|
260 | $tableName = $this->owner->tableName(); |
|
261 | $like = strtr($this->getParentPath() . $this->delimiter, ['%' => '\%', '_' => '\_', '\\' => '\\\\']); |
|
262 | $query = $this->owner->find() |
|
263 | ->andWhere(['like', "{$tableName}.[[{$this->pathAttribute}]]", $like . '%', false]) |
|
264 | ->andWhere(["{$tableName}.[[{$this->depthAttribute}]]" => $this->owner->getAttribute($this->depthAttribute)]) |
|
265 | ->andWhere(['<', "{$tableName}.[[{$this->sortAttribute}]]", $this->owner->getAttribute($this->sortAttribute)]) |
|
266 | ->andWhere($this->treeCondition()) |
|
267 | ->orderBy(["{$tableName}.[[{$this->sortAttribute}]]" => SORT_DESC]) |
|
268 | ->limit(1); |
|
269 | $query->multiple = false; |
|
270 | return $query; |
|
271 | } |
|
272 | ||
273 | /** |
|
274 | * @return \yii\db\ActiveQuery |
|
@@ 276-289 (lines=14) @@ | ||
273 | /** |
|
274 | * @return \yii\db\ActiveQuery |
|
275 | */ |
|
276 | public function getNext() |
|
277 | { |
|
278 | $tableName = $this->owner->tableName(); |
|
279 | $like = strtr($this->getParentPath() . $this->delimiter, ['%' => '\%', '_' => '\_', '\\' => '\\\\']); |
|
280 | $query = $this->owner->find() |
|
281 | ->andWhere(['like', "{$tableName}.[[{$this->pathAttribute}]]", $like . '%', false]) |
|
282 | ->andWhere(["{$tableName}.[[{$this->depthAttribute}]]" => $this->owner->getAttribute($this->depthAttribute)]) |
|
283 | ->andWhere(['>', "{$tableName}.[[{$this->sortAttribute}]]", $this->owner->getAttribute($this->sortAttribute)]) |
|
284 | ->andWhere($this->treeCondition()) |
|
285 | ->orderBy(["{$tableName}.[[{$this->sortAttribute}]]" => SORT_ASC]) |
|
286 | ->limit(1); |
|
287 | $query->multiple = false; |
|
288 | return $query; |
|
289 | } |
|
290 | ||
291 | /** |
|
292 | * @return bool |