1

here is some minor question but it always bother me while doing the code with magento.

$resource = Mage::getSingleton('core/resource');
$write = $resource->getConnection('core_write');
$table = $resource->getTableName('your/model');
$write->delete(
    $table,
    ['entity_id IN (?)' => [123, 456]]
);
$write->update(
    $table,
    ['column_1' => 3, 'column_2' => 4],
    ['entity_id = ?' => 123]
);

If I use above code to write into DB and I am not sure which query will be formed actually. How would I print the formed SQL through above write object.

I just know this one:

echo $collection->getSelect() 

In which I can get the select query printed on the screen.

Can you please suggest me so that I can get the query which is going to execute or which is executed in last.

Thank you :)

1

try as below

echo $collection->getSelect()->__toString();
  • Thanks for the comment but this is not what I am looking for. I want to print the query which is being executed through core_write object – Mansi Raja Apr 25 at 7:28
  • 1
    @MansiRaja give this a try – Piyush Apr 25 at 9:58
  • It works.. exactly what I need.. found in log.. thanks buddy :) – Mansi Raja Apr 25 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.