Fixed params replacements
Change-Id: I3e6dfbdd3c756f53dce0c2c6a5835a4c7dd6a098
This commit is contained in:
parent
9d7ea70c35
commit
1ef61bae20
@ -46,9 +46,23 @@ class DoctrineFilterMapping extends FilterMapping
|
||||
*/
|
||||
public function apply(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
return $query->andWhere($where)->setParameter(":value_".$param_count, $filter->getValue());
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
$query = $query->andWhere($where);
|
||||
|
||||
if($has_param){
|
||||
$query = $query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,9 +72,21 @@ class DoctrineFilterMapping extends FilterMapping
|
||||
*/
|
||||
public function applyOr(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
if($has_param){
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
}
|
@ -52,11 +52,28 @@ class DoctrineJoinFilterMapping extends FilterMapping
|
||||
*/
|
||||
public function apply(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
if(!in_array($this->alias, $query->getAllAliases()))
|
||||
$query->innerJoin($this->table, $this->alias, Join::WITH);
|
||||
return $query->andWhere($where)->setParameter(":value_".$param_count, $filter->getValue());
|
||||
|
||||
$query = $query->andWhere($where);
|
||||
|
||||
if($has_param){
|
||||
$query = $query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
|
||||
return $query;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,11 +83,23 @@ class DoctrineJoinFilterMapping extends FilterMapping
|
||||
*/
|
||||
public function applyOr(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
if(!in_array($this->alias, $query->getAllAliases()))
|
||||
$query->innerJoin($this->table, $this->alias, Join::WITH);
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
|
||||
if($has_param){
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
@ -26,12 +26,27 @@ class DoctrineLeftJoinFilterMapping extends DoctrineJoinFilterMapping
|
||||
*/
|
||||
public function apply(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
if(!in_array($this->alias, $query->getAllAliases()))
|
||||
$query->leftJoin($this->table, $this->alias, Join::WITH);
|
||||
|
||||
return $query->andWhere($where)->setParameter(":value_".$param_count, $filter->getValue());
|
||||
$query = $query->andWhere($where);
|
||||
|
||||
if($has_param){
|
||||
$query = $query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,11 +56,26 @@ class DoctrineLeftJoinFilterMapping extends DoctrineJoinFilterMapping
|
||||
*/
|
||||
public function applyOr(QueryBuilder $query, FilterElement $filter){
|
||||
$param_count = $query->getParameters()->count() + 1;
|
||||
$where = str_replace(":value", ":value_".$param_count, $this->where);
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
$where = $this->where;
|
||||
$has_param = false;
|
||||
|
||||
if(strstr($where,":value")) {
|
||||
$where = str_replace(":value", ":value_" . $param_count, $where);
|
||||
$has_param = true;
|
||||
}
|
||||
|
||||
if(strstr($where,":operator"))
|
||||
$where = str_replace(":operator", $filter->getOperator(), $where);
|
||||
|
||||
if(!in_array($this->alias, $query->getAllAliases()))
|
||||
$query->leftJoin($this->table, $this->alias, Join::WITH);
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
|
||||
if(!in_array($this->alias, $query->getAllAliases()))
|
||||
$query->leftJoin($this->table, $this->alias, Join::WITH);
|
||||
|
||||
if($has_param){
|
||||
$query->setParameter(":value_".$param_count, $filter->getValue());
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user