0

I just want to print and check the insert query in magento. I have searched in google and tried alot but not able to print the insert query in magento.

My code:

  $insert = Mage::getModel('instagram/instagram');
        $insert->setData('username',$data->user->username);
        $insert->setData('name',$data->user->full_name);
        $insert->setData('Bio',$data->user->bio);
        $insert->setData('Website',$data->user->website);
        $insert->setData('user_id',$data->user->id);
        $insert->setData('instagram_access_token',$data->access_token);
        $insert->save();

Can anyone tell me to do???

3
  • Do you have a Magento collection code for this? Commented Sep 9, 2015 at 13:15
  • I have updated, pls check it. Commented Sep 9, 2015 at 13:35
  • Should be migrated to magento.stackexchange.com (?) Commented Sep 11, 2015 at 7:46

2 Answers 2

2

Go to Varien_Db_Adapter_Pdo_Mysql under lib/Varien/Db/Adapter/Pdo/Mysql.php and change global variables :

protected $_debug               = false;
protected $_logAllQueries       = false;

to

protected $_debug               = true;
protected $_logAllQueries       = true;

then run your script and you should see the query under var/debug/pdo_mysql.log or whatever file specified in

protected $_debugFile           = 'var/debug/pdo_mysql.log';

Don't forget to restore all modified values when you finish logging the query, if the file do not exists after running the script, make sure that magento has permissions under that directory

Sign up to request clarification or add additional context in comments.

2 Comments

I had done the steps that you have mentioned, but i did not get the query in log file.
Do you have enable logging?, check in admin panel System > Configuration > Developer > Log Settings, also make sure that folder var/log has 777 permissions
0

Try following

$insert = Mage::getModel('instagram/instagram');
echo $insert->getSelect()->__toString(); 

1 Comment

I think this will print only select query, I asked for printing insert query.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.