A:使える
こんな場合↓
if ($status)
{
$q->where('status = ?', $status);
}
$q->andWhere('hoge = ?', $hoge);
いきなり「andWhere」がきてもOKっす!
参考:lib/vendor/doctrine/Doctrine/Query/Abstract.php
public function andWhere($where, $params = array())
{
if (is_array($params)) {
$this->_params['where'] = array_merge($this->_params['where'], $params);
} else {
$this->_params['where'][] = $params;
}
if ($this->_hasDqlQueryPart('where')) {
$this->_addDqlQueryPart('where', 'AND', true);
}
return $this->_addDqlQueryPart('where', $where, true);
}
※注意:「->where()」を使うとそれまでの条件指定が初期化されてしまう
↓
1663 public function where($where, $params = array())
1664 {
1665 $this->_params['where'] = array();
【豆知識】
andWahere = addWhere