0

I need to make an sql sentence where i retrieve records filtered by 'scope' value from core_config_data table. This is the script:

$query = "SELECT * FROM  `core_config_data` WHERE  `scope` = $scope";

I get $scope with this line:

$scope = Mage::getSingleton('adminhtml/config_data')->getScope();

But when i run this, i receive an error saying:

An error occurred while saving this configuration: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'stores' in 'where clause'

When i run the same sql sentence in phpmyadmin, it works fine and it retrieves the correct record, so i don't know what's wrong here.

Thanks for helping

0

The problem is, that you don't escap $scope, so mysql thinks that the value of $scope is a column instead of a string. add a few ` around it.

  • Thanks dude, in fact i had to add ' to the variable. Cheers.- – Guille Apr 9 '14 at 19:07

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.