How to use MySQL FIND_IN_SET() in Magento Collection
In Magento, we have "finset" keyword to filter collection with comma separated column field value.
For example: If myid field have string comma separated value like 2,4,65,22 and we want the record having 4 in myid field.
Then follows the below example to get the match records:
$collection = Mage::getResourceModel('modulename/modelname_collection');
$collection->addFieldToFilter('main_table.myid',array("finset"=>array('4')));
For example: If myid field have string comma separated value like 2,4,65,22 and we want the record having 4 in myid field.
Then follows the below example to get the match records:
$collection = Mage::getResourceModel('modulename/modelname_collection');
$collection->addFieldToFilter('main_table.myid',array("finset"=>array('4')));
How to use MySQL FIND_IN_SET() in Magento Collection
Reviewed by Web Technology Funda
on
6:00:00 AM
Rating:
No comments