forked from propelorm/Propel2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request propelorm#919 from SCIF/master
Some improvements of DelegateBehavior
- Loading branch information
Showing
2 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Propel/Generator/Behavior/Delegate/templates/queryMethodsTemplate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Filter the query by <?=$fieldName?> column | ||
* | ||
* Example usage: | ||
* <code> | ||
* $query->filterBy<?=$phpName?>(1234); // WHERE <?=$fieldName?> = 1234 | ||
* $query->filterBy<?=$phpName?>(array(12, 34)); // WHERE <?=$fieldName?> IN (12, 34) | ||
* $query->filterBy<?=$phpName?>(array('min' => 12)); // WHERE <?=$fieldName?> > 12 | ||
* </code> | ||
* | ||
* @param mixed $value The value to use as filter. | ||
* Use scalar values for equality. | ||
* Use array values for in_array() equivalent. | ||
* Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. | ||
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL | ||
* | ||
* @return $this|<?=$childClassName?> The current query, for fluid interface | ||
*/ | ||
public function filterBy<?=$phpName?>($value = null, $comparison = null) | ||
{ | ||
return $this->use<?=$tablePhpName?>Query()->filterBy<?=$phpName?>($value, $comparison)->endUse(); | ||
} | ||
|
||
/** | ||
* Adds an ORDER BY clause to the query | ||
* Usability layer on top of Criteria::addAscendingOrderByColumn() and Criteria::addDescendingOrderByColumn() | ||
* Infers $column and $order from $columnName and some optional arguments | ||
* Examples: | ||
* $c->orderBy('Book.CreatedAt') | ||
* => $c->addAscendingOrderByColumn(BookTableMap::CREATED_AT) | ||
* $c->orderBy('Book.CategoryId', 'desc') | ||
* => $c->addDescendingOrderByColumn(BookTableMap::CATEGORY_ID) | ||
* | ||
* @param string $order The sorting order. Criteria::ASC by default, also accepts Criteria::DESC | ||
* | ||
* @return $this|ModelCriteria The current object, for fluid interface | ||
*/ | ||
public function orderBy<?=$phpName?>($order = Criteria::ASC) | ||
{ | ||
return $this->use<?=$tablePhpName?>Query()->orderBy<?=$phpName?>($order)->endUse(); | ||
} |