Skip to content

Commit

Permalink
Ticket #1503 - jDaoConditions should satinize order input
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentj committed Mar 14, 2013
1 parent 0344778 commit 10879b8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/jelix/dao/jDaoConditions.class.php
Expand Up @@ -92,8 +92,11 @@ function __construct ($glueOp = 'AND'){
* @param string $field_id the property name used to order results
* @param string $way the order type : asc or desc
*/
function addItemOrder($field_id, $way='ASC'){
$this->order[$field_id]=$way;
function addItemOrder ($field_id, $way='ASC') {
$way = strtoupper($way);
if ($way !='DESC' && $way != 'ASC')
throw new jException('jelix~dao.error.bad.operator', $way);
$this->order[$field_id] = $way;
}

/**
Expand Down Expand Up @@ -129,6 +132,9 @@ function hasConditions (){
* @param string $glueOp the logical operator which links each conditions in the group : AND or OR
*/
function startGroup ($glueOp = 'AND'){
$glueOp = strtoupper($glueOp);
if ($glueOp !='AND' && $glueOp != 'OR')
throw new jException('jelix~dao.error.bad.operator', $glueOp);
$cond= new jDaoCondition ($glueOp, $this->_currentCondition);
$this->_currentCondition = $cond;
}
Expand Down Expand Up @@ -164,6 +170,5 @@ function addCondition ($field_id, $operator, $value, $foo = false){
}
else
throw new jException('jelix~dao.error.bad.operator', $operator);

}
}

0 comments on commit 10879b8

Please sign in to comment.