I've a custom module with custom table, now, i'm trying to make something like a filter for that table,
Mage::getModel('comunity/news')->getCollection()
->addFieldToFilter('title', array('like'=>'%'.$this->getRequest()->getParam('q').'%'));
with this is enough, and works perfect, but i need to add another field, is simple if you do like this
Mage::getModel('comunity/news')->getCollection()
->addFieldToFilter('title', array('like'=>'%'.$this->getRequest()->getParam('q').'%'))
->addFieldToFilter('shortdesc', array('like'=>'%'.$this->getRequest()->getParam('q').'%'));
it works to, but it make an (AND) and i want an (OR), i was lookin into Varien_Data_Collection_Db class, the function addFieldToFilter make a call to _getConditionSql where you can see something like this
if (is_array($fieldName)) {
foreach ($fieldName as $f) {
$orSql = array();
foreach ($condition as $orCondition) {
$orSql[] = '('.$this->_getConditionSql($f[0], $f[1]).')';
}
$sql = '('. join(' or ', $orSql) .')';
}
return $sql;
}
here an (OR) can be done, i've tried with
->addFieldToFilter(array (
array('field'=>'title', 'like'=>'%'.$this->getRequest()->getParam('q').'%'),
array('field'=>'shortdesc', 'like'=>'%'.$this->getRequest()->getParam('q').'%'),
))
but the query it makes is
SELECT `main_table`.* FROM `uhma_comunidad_articulos` AS `main_table` WHERE (())
i need some help here thanks