prestashop_newuser Posted January 1, 2015 Share Posted January 1, 2015 (edited) I am a newbie in Prestashop. I am doing a small module. In that module I want to update a table. But my condition is like this it will update those rows whose id is not 3. So for me my table is like this id name status1 test1 02 test4 03 test5 14 test9 05 test12 06 test25 0 So as per DB classes I made my query like this $id = 3;Db::getInstance()->update('table', array('status'=>'1'), 'id != '.$id ); also I have tried Db::getInstance()->update('table', array('status'=>'1'), 'id <> '.$id ); But its not working. So can someone kindly tell me how to fix this. Any help and suggestions will be really appreciable. Thanks Edited January 1, 2015 by prestashop_newuser (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted January 1, 2015 Share Posted January 1, 2015 What you have done looks correct, but 'not working' isn't enough information to go by. If you are having trouble using the update function, then just execute either of these queries Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'table SET `status` = 1 WHERE `id` != '. (int)$id); Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'table SET `status` = 1 WHERE `id` <> '. (int)$id); Link to comment Share on other sites More sharing options...
prestashop_newuser Posted January 1, 2015 Author Share Posted January 1, 2015 What you have done looks correct, but 'not working' isn't enough information to go by. If you are having trouble using the update function, then just execute either of these queries Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'table SET `status` = 1 WHERE `id` != '. (int)$id); Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'table SET `status` = 1 WHERE `id` <> '. (int)$id); Nope this is not working. I have used your suggested code and it showed error like this mymodule (parse error in /modules/mymodule/mymodule.php) When I removing this line of code.Everything seems to be okay. Link to comment Share on other sites More sharing options...
bellini13 Posted January 1, 2015 Share Posted January 1, 2015 hard to say without seeing the entire code and what you have done. that single line of code I provided you is syntactically correct, so the issue may be how you have implemented it Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now