I have a call to a model which is just a standard class (not extending zend_db_table). I am doing a select and want to have the possibility of excluding a set of ids which which would be passed in as a variable.
I curently have the following:
public function getItemsBySection($section, $excluded_ids=null){
//handle this as special case (although only case at this point)
if(is_array($excluded_ids) and count($excluded_ids)>0){
$x=1;
foreach($excluded_ids as $key=>$value){
if($x==1){
$not_in=$value;
}else{
$not_in.=','.$value;
}
$x++;
}
}
if($section=='feed_supplies'){
$sql='select * from items where is_feed_supply=1';
if($not_in){
$sql.=' and id not in ('.$not_in.')';
}
}
echo $sql . '<br/>';
$results=$this->_db->fetchAll($sql);
but was wondering if there is a way to use Zend_Db_Expr or some other concstruct to handle the exclusion of certain items? I'm not error handling like if it is an integer etc...
I personally am not that big of a fan of the zend_db_select syntax but could be persuaded if it fixes things like this (want to see Doctrine2).
thanks