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')));
How to use MySQL FIND_IN_SET() in Magento Collection How to use MySQL FIND_IN_SET() in Magento Collection Reviewed by Pranay Gondane on 6:00:00 AM Rating: 5

No comments

Free! Free!Free! Subscribe to Get Free PHP (Magento) tutorial Update in Your Inbox!!! Hurry Up!!!