@@ 140-155 (lines=16) @@ | ||
137 | * Named scope. Gets previous sibling of node. |
|
138 | * @return CActiveRecord the owner. |
|
139 | */ |
|
140 | public function prev() |
|
141 | { |
|
142 | $owner=$this->getOwner(); |
|
143 | $db=$owner->getDbConnection(); |
|
144 | $criteria=$owner->getDbCriteria(); |
|
145 | $alias=$db->quoteColumnName($owner->getTableAlias()); |
|
146 | $criteria->addCondition($alias.'.'.$db->quoteColumnName($this->rightAttribute).'='.($owner->{$this->leftAttribute}-1)); |
|
147 | ||
148 | if($this->hasManyRoots) |
|
149 | { |
|
150 | $criteria->addCondition($alias.'.'.$db->quoteColumnName($this->rootAttribute).'='.CDbCriteria::PARAM_PREFIX.CDbCriteria::$paramCount); |
|
151 | $criteria->params[CDbCriteria::PARAM_PREFIX.CDbCriteria::$paramCount++]=$owner->{$this->rootAttribute}; |
|
152 | } |
|
153 | ||
154 | return $owner; |
|
155 | } |
|
156 | ||
157 | /** |
|
158 | * Named scope. Gets next sibling of node. |
|
@@ 161-176 (lines=16) @@ | ||
158 | * Named scope. Gets next sibling of node. |
|
159 | * @return CActiveRecord the owner. |
|
160 | */ |
|
161 | public function next() |
|
162 | { |
|
163 | $owner=$this->getOwner(); |
|
164 | $db=$owner->getDbConnection(); |
|
165 | $criteria=$owner->getDbCriteria(); |
|
166 | $alias=$db->quoteColumnName($owner->getTableAlias()); |
|
167 | $criteria->addCondition($alias.'.'.$db->quoteColumnName($this->leftAttribute).'='.($owner->{$this->rightAttribute}+1)); |
|
168 | ||
169 | if($this->hasManyRoots) |
|
170 | { |
|
171 | $criteria->addCondition($alias.'.'.$db->quoteColumnName($this->rootAttribute).'='.CDbCriteria::PARAM_PREFIX.CDbCriteria::$paramCount); |
|
172 | $criteria->params[CDbCriteria::PARAM_PREFIX.CDbCriteria::$paramCount++]=$owner->{$this->rootAttribute}; |
|
173 | } |
|
174 | ||
175 | return $owner; |
|
176 | } |
|
177 | ||
178 | /** |
|
179 | * Create root node if multiple-root tree mode. Update node if it's not new. |