| 134 | | } |
|---|
| | 142 | } |
|---|
| | 143 | |
|---|
| | 144 | /** |
|---|
| | 145 | * Adds a condition on a column based on a propertyPath and a value |
|---|
| | 146 | * Uses introspection to translate the propertyPath into a fully qualified name |
|---|
| | 147 | * <code> |
|---|
| | 148 | * $c->filterBy('Relation.Title', 'table_alias.foo'); |
|---|
| | 149 | * </code> |
|---|
| | 150 | * |
|---|
| | 151 | * @see Criteria::add() |
|---|
| | 152 | * |
|---|
| | 153 | * @param string $column A string representing thecolumn phpName, e.g. 'AuthorId' |
|---|
| | 154 | * @param mixed $value A value for the condition |
|---|
| | 155 | * @param string $comparison What to use for the column comparison, defaults to Criteria::EQUAL |
|---|
| | 156 | * |
|---|
| | 157 | * @return ModelCriteria The current object, for fluid interface |
|---|
| | 158 | */ |
|---|
| | 159 | public function filterBy($column, $value, $comparison = Criteria::EQUAL) |
|---|
| | 160 | { |
|---|
| | 161 | // check if an objectPath has been given |
|---|
| | 162 | $lastDot = strrpos($column, '.'); |
|---|
| | 163 | if ($lastDot !== false) |
|---|
| | 164 | { |
|---|
| | 165 | // get the objectPath |
|---|
| | 166 | $objectPath = substr($column, 0, $lastDot); |
|---|
| | 167 | |
|---|
| | 168 | // and get Related Query Class |
|---|
| | 169 | $strRelated = $this->translateObjectPathToAlias($objectPath); |
|---|
| | 170 | $column = $strRelated.'.'.substr($column, $lastDot + 1); |
|---|
| | 171 | |
|---|
| | 172 | // TODO: this can be removed when filterBy is patched in propel |
|---|
| | 173 | return $this->useQuery($strRelated) |
|---|
| | 174 | ->filterBy($column, $value, $comparison) |
|---|
| | 175 | ->endUse();; |
|---|
| | 176 | } |
|---|
| | 177 | |
|---|
| | 178 | return parent::filterBy($column, $value, $comparison); |
|---|
| | 179 | } |
|---|
| | 180 | |
|---|
| | 181 | |
|---|
| | 182 | /** |
|---|
| | 183 | * Adds an ORDER BY clause to the query |
|---|
| | 184 | * Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() |
|---|
| | 185 | * Infers $column and $order from $columnName and some optional arguments |
|---|
| | 186 | * Examples: |
|---|
| | 187 | * $c->orderBy('Book.CreatedAt') |
|---|
| | 188 | * => $c->addAscendingOrderByColumn(BookPeer::CREATED_AT) |
|---|
| | 189 | * $c->orderBy('Book.CategoryId', 'desc') |
|---|
| | 190 | * => $c->addDescendingOrderByColumn(BookPeer::CATEGORY_ID) |
|---|
| | 191 | * |
|---|
| | 192 | * @param string $columnName The column to order by |
|---|
| | 193 | * @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC |
|---|
| | 194 | * |
|---|
| | 195 | * @return ModelCriteria The current object, for fluid interface |
|---|
| | 196 | */ |
|---|
| | 197 | public function orderBy($columnName, $order = Criteria::ASC) |
|---|
| | 198 | { |
|---|
| | 199 | // check if an objectPath has been given |
|---|
| | 200 | $lastDot = strrpos($columnName, '.'); |
|---|
| | 201 | if ($lastDot !== false) |
|---|
| | 202 | { |
|---|
| | 203 | // get the objectPath |
|---|
| | 204 | $objectPath = substr($columnName, 0, $lastDot); |
|---|
| | 205 | |
|---|
| | 206 | // and get Related Query Class |
|---|
| | 207 | $strRelated = $this->translateObjectPathToAlias($objectPath); |
|---|
| | 208 | $columnName = $strRelated.'.'.substr($columnName, $lastDot + 1); |
|---|
| | 209 | |
|---|
| | 210 | // return $this->useQuery($strRelated) |
|---|
| | 211 | // ->orderBy($columnName, $order) |
|---|
| | 212 | // ->endUse();; |
|---|
| | 213 | } |
|---|
| | 214 | |
|---|
| | 215 | return parent::orderBy($columnName, $order); |
|---|
| | 216 | } |
|---|