php - Collection addFieldToFilter does not filtering -


i have non-eav model, , want filter on collection below

$td_trans_collection = mage::getmodel('tichdiem/scoretransaction')->getcollection();         $td_trans_collection->addfieldtofilter('increment_id', $incrementid)                     ->addfieldtofilter('action', self::tichdiem_add)                     ->load(); 

the query produce by

 $td_trans_collection->getselect()->__tostring(); 

return

 select `main_table`.* `fhs_td_score_transaction` `main_table` (increment_id = '100010565') , (action = '0') 

which correct query, should return 1 answer. ran query on terminal well. however, when loop through collection

 foreach($td_trans_collection $item){      echo $item;  } 

i got every entries inside table, why case? using magento 1.9.1

first, test select query directly in database see returns. if it's returning 1 row want means somewhere in magento, modifying collection perhaps.

alternatively, can try method limit collection 1 result:

$td_trans_collection->getselect()->limit(1); 

you can try:

$td_trans_collection->getfirstitem()->getdata(); 

if reliably returns result want, problem solved.

if above fails, go to: lib/varien/db/adapter/pdo/mysql.php , locate following properties , change them shown below:

protected $_debug               = true; protected $_logallqueries       = true; 

after set values true, run collection again. go to: var/debug/pdo_mysql.log , take careful @ final queries executed. hopefully, give better clue what's happening.

additionally, remove ->load();


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -