| @@ 231-245 (lines=15) @@ | ||
| 228 | /** |
|
| 229 | * @return \yii\db\ActiveQuery |
|
| 230 | */ |
|
| 231 | public function getPrev() |
|
| 232 | { |
|
| 233 | $tableName = $this->owner->tableName(); |
|
| 234 | $query = $this->owner->find() |
|
| 235 | ->andWhere([ |
|
| 236 | 'and', |
|
| 237 | ['<', "{$tableName}.[[{$this->rightAttribute}]]", $this->owner->getAttribute($this->leftAttribute)], |
|
| 238 | ['>', "{$tableName}.[[{$this->rightAttribute}]]", $this->getParent()->select([$this->leftAttribute])], |
|
| 239 | ]) |
|
| 240 | ->andWhere($this->treeCondition()) |
|
| 241 | ->orderBy(["{$tableName}.[[{$this->rightAttribute}]]" => SORT_DESC]) |
|
| 242 | ->limit(1); |
|
| 243 | $query->multiple = false; |
|
| 244 | return $query; |
|
| 245 | } |
|
| 246 | ||
| 247 | /** |
|
| 248 | * @return \yii\db\ActiveQuery |
|
| @@ 250-264 (lines=15) @@ | ||
| 247 | /** |
|
| 248 | * @return \yii\db\ActiveQuery |
|
| 249 | */ |
|
| 250 | public function getNext() |
|
| 251 | { |
|
| 252 | $tableName = $this->owner->tableName(); |
|
| 253 | $query = $this->owner->find() |
|
| 254 | ->andWhere([ |
|
| 255 | 'and', |
|
| 256 | ['>', "{$tableName}.[[{$this->leftAttribute}]]", $this->owner->getAttribute($this->rightAttribute)], |
|
| 257 | ['<', "{$tableName}.[[{$this->leftAttribute}]]", $this->getParent()->select([$this->rightAttribute])], |
|
| 258 | ]) |
|
| 259 | ->andWhere($this->treeCondition()) |
|
| 260 | ->orderBy(["{$tableName}.[[{$this->leftAttribute}]]" => SORT_ASC]) |
|
| 261 | ->limit(1); |
|
| 262 | $query->multiple = false; |
|
| 263 | return $query; |
|
| 264 | } |
|
| 265 | ||
| 266 | /** |
|
| 267 | * Populate children relations for self and all descendants |
|