added whereIn
This commit is contained in:
parent
48481be4bd
commit
1c919c7a0a
@ -71,6 +71,35 @@ abstract class Doctrine_Query_Abstract extends Doctrine_Hydrate
|
|||||||
}
|
}
|
||||||
return $this->parseQueryPart('where', $where, true);
|
return $this->parseQueryPart('where', $where, true);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* whereIn
|
||||||
|
* adds IN condition to the query WHERE part
|
||||||
|
*
|
||||||
|
* @param string $expr
|
||||||
|
* @param mixed $params an array of parameters or a simple scalar
|
||||||
|
* @return Doctrine_Query
|
||||||
|
*/
|
||||||
|
public function whereIn($params = array())
|
||||||
|
{
|
||||||
|
if (is_array($params)) {
|
||||||
|
$this->_params = array_merge($this->_params, $params);
|
||||||
|
} else {
|
||||||
|
$this->_params[] = $params;
|
||||||
|
}
|
||||||
|
$a = array();
|
||||||
|
foreach ($params as $k => $value) {
|
||||||
|
if ($value instanceof Doctrine_Expression) {
|
||||||
|
$value = $value->getSql();
|
||||||
|
unset($values[$k]);
|
||||||
|
} else {
|
||||||
|
$value = '?';
|
||||||
|
}
|
||||||
|
$a[] = $value;
|
||||||
|
}
|
||||||
|
$where = $expr . ' IN (' . implode(', ', $a) . ')';
|
||||||
|
|
||||||
|
return $this->parseQueryPart('where', $where, true);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* addGroupBy
|
* addGroupBy
|
||||||
* adds fields to the GROUP BY part of the query
|
* adds fields to the GROUP BY part of the query
|
||||||
|
Loading…
x
Reference in New Issue
Block a user