Arpels Posted March 14, 2017 Share Posted March 14, 2017 What i'm I doing wrong ? $result = Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'orders` SET `delivery_date` = '.$planning_delivery->date_delivery); Notice: Undefined variable: planning_delivery in /homepages/39/d606972938/htdocs/prestashop-uat/modules/planningdeliverybycarrier/planningdeliverybycarrier.php on line 557 Notice: Trying to get property of non-object in /homepages/39/d606972938/htdocs/prestashop-uat/modules/planningdeliverybycarrier/planningdeliverybycarrier.php on line 557 [PrestaShopDatabaseException] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 UPDATE `ps_orders` SET `delivery_date` = at line 791 in file classes/db/Db.php 786. if ($webservice_call && $errno) { 787. $dbg = debug_backtrace(); 788. WebserviceRequest::getInstance()->setError(500, '[SQL Error] '.$this->getMsgError().'. From '.(isset($dbg[3]['class']) ? $dbg[3]['class'] : '').'->'.$dbg[3]['function'].'() Query was : '.$sql, 97); 789. } elseif (_PS_DEBUG_SQL_ && $errno && !defined('PS_INSTALLATION_IN_PROGRESS')) { 790. if ($sql) { 791. throw new PrestaShopDatabaseException($this->getMsgError().'<br /><br /><pre>'.$sql.'</pre>'); 792. } 793. 794. throw new PrestaShopDatabaseException($this->getMsgError()); 795. } 796. } Thanks for your help... Link to comment Share on other sites More sharing options...
vekia Posted March 14, 2017 Share Posted March 14, 2017 you use some custom module and the problem is with this addon. we dont know the code that this module has, but the error says that variable in this code: $planning_delivery does not exist so in effect you've got error in mysql query in this case it is necessary to analyse the code and apply fixes. Due to the fact that his is non-default module without possibility to check it its almost impossible to help. i think that it will be much easier to contact with module developer module is "planingdeliverybycarrier" Link to comment Share on other sites More sharing options...
Arpels Posted March 15, 2017 Author Share Posted March 15, 2017 (edited) Hello Vekia, thanks for you feedback. You're right it's a custom module and my support is out of date. I just want to update the delivery date in ps_orders when it's inserted in the related table of the module. I checked the code and think found the right place to do so as below, and the variable does exist, but maybe not where I put my query. Here is the sample of code above : code removed Edited March 18, 2017 by Arpels (see edit history) Link to comment Share on other sites More sharing options...
Arpels Posted March 18, 2017 Author Share Posted March 18, 2017 (edited) I got it worked with the following : Db::getInstance()->execute('UPDATE `'._DB_PREFIX_.'orders` SET `delivery_date`='.$planning_delivery->date_delivery.' WHERE `id_order` = '.$params['order']->id); But I have this message : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '00:00:00 WHERE `id_order` = 141' at line 1 query fired : UPDATE `ps_orders` SET `delivery_date`=2017-03-22 00:00:00 WHERE `id_order` = 141 Edited March 18, 2017 by Arpels (see edit history) Link to comment Share on other sites More sharing options...
dolrichfortich Posted March 19, 2017 Share Posted March 19, 2017 (edited) You are missing the single quotes from the delivery date. It should be like this. Db::getInstance()->execute("UPDATE `"._DB_PREFIX_."orders` SET `delivery_date`='".$planning_delivery->date_delivery."' WHERE `id_order` = ".$params['order']->id); Edited March 19, 2017 by dolrichfortich (see edit history) Link to comment Share on other sites More sharing options...
Arpels Posted March 19, 2017 Author Share Posted March 19, 2017 Hello, Thanks, the error is gone, but the datatable fields don't get updated. I think it's because the insertion of the ps_order rows is made after my UPDATE query. How can I make achieve my update afterward ? Link to comment Share on other sites More sharing options...
dolrichfortich Posted March 19, 2017 Share Posted March 19, 2017 Sorry, can't answer your question without looking at the whole code. Link to comment Share on other sites More sharing options...
Arpels Posted March 20, 2017 Author Share Posted March 20, 2017 Hello ! I found the solution ! topic closed Thanks 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