I have saved a url in the db. The url is: http://localhost/magento/index.php/electronics/cameras.html?cat=25&price=-100
$url = Mage::getSingleton('core/session')->getStateUrl(); $filterstate = Mage::getSingleton('core/session')->getFilterState(); $inc= 1; foreach($filterstate as $key=>$value): if($inc==1){ $searchurl = $url."?".$key.'='.$value;} if($inc!=1){ $searchurl.= '&'.$key.'='.$value; } $inc++; endforeach;
when i search for the field in the db with my collection
$detect_duplicate = Mage::getResourceModel('savesearch/savesearch_collection'); $detect_duplicate->addFieldToFilter('content', array('like' => $searchurl)); echo $detect_duplicate->getSelect();
The result i got is
SELECT `main_table`.* FROM `savesearch` AS `main_table` WHERE (content LIKE 'http://localhost/magento/index.php/electronics/cameras.html''cat=25&price=-100')
For some reason the ? is emptied. But when i replace it with other characters like * the result was
SELECT `main_table`.* FROM `savesearch` AS `main_table` WHERE (content LIKE 'http://localhost/magento/index.php/electronics/cameras.html*cat=25&price=-100')
Can someone suggest a fix for this. I should able to search for a URL in Db to avoid duplication.