maria zagula Posted April 21, 2016 Share Posted April 21, 2016 Hi experts! I have very simple code: $aaa = Db::getInstance()->insert('feature_product', array( 'id_feature' => $id_feature, 'id_product' => $id_product, 'id_feature_value' => $id_feature_value, )); an this code does not works hovewer if I add d($aaa) after the code $aaa = Db::getInstance()->insert('feature_product', array( 'id_feature' => $id_feature, 'id_product' => $id_product, 'id_feature_value' => $id_feature_value, ));*/ d($aaa); I get message '1' and database updates correctly ! 1. I have tried with Db::getInstance()->execute($sql); and it gives me exactly the same behaviour. 2. In other part of the code I have almost identical function and it works withour any problems etc. Thanks in advance for help! Link to comment Share on other sites More sharing options...
NemoPS Posted April 22, 2016 Share Posted April 22, 2016 Try getting rid of that last comma in the array, after $id_feature_value Link to comment Share on other sites More sharing options...
maria zagula Posted April 23, 2016 Author Share Posted April 23, 2016 Thanks for your reply !Unfortunatelly this is not the case (or I do not understand something). This is the whole code of actionProductSave hook public function hookActionProductSave($params) { $id_feature = 10; $id_feature_value = 43; if (isset($params['id_product'])) { $id_product=$params['id_product']; if($params['product']->date_add<$params['product']->available_date) { $sql = 'SELECT * FROM '._DB_PREFIX_.'feature_product WHERE id_product='.$id_product.' AND id_feature='.$id_feature; $results = Db::getInstance()->ExecuteS($sql); if (!$results) { Db::getInstance(_PS_USE_SQL_SLAVE_)->insert('feature_product', array( 'id_feature' => $id_feature, 'id_product' => $id_product, 'id_feature_value' => $id_feature_value )); //d('anything'); } } } return 'anything'; } If I have "d('anything');" commentened nothing works. If i have d('anything') not commented my database updates properly :/ Anybody have any idea why simple d() influance the code so much ? Best regards and thanks in advance ! Link to comment Share on other sites More sharing options...
NemoPS Posted April 25, 2016 Share Posted April 25, 2016 There is a chance something else runs after that, if you don't kill the script. Depending on where you run the hook. In 1.6+ it's better to use hookActionProductUpdate anyway.Also turn on error reporting, a simple insert should die on duplicate keys 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