JoeSatriani Posted February 16, 2017 Share Posted February 16, 2017 (edited) Bonjour, J'apporte des modifications a un module prestashop 1.6.4. Mais toute mes tentatives ont échoué. Merci d'avance de votre aide voici mon code: $tmp_four = $this->Get_All_From_Tmp_Four(); //var_dump($tab_product); foreach ($tmp_four as $key) { $quantite_a_recep = $key['quantite_resultat']; $qte_recep = $key['quantite_receptionnee']; $products_id = $key['id_product']; $modif_qte_a_recep = ($quantite_a_recep - $qte_recep); $this->Get_Update_Quantite_A_Receptionner($modif_qte_a_recep, $products_id); private function Get_All_From_Tmp_Four() { return Db::getInstance()->executeS("SELECT * FROM `tmp_cmd_four` ORDER BY `name_supplier` ASC"); } private function Get_Update_Quantite_A_Receptionner($modif_qte_a_recep, $products_id) { # Exécution de la requête SQL /* avec update */ $data = 'quantite_a_receptionner'; $where = 'id_product'; $update = Db::getInstance()->update('tmp_cmd_four', array($data => $modif_qte_a_recep), "'.$where.' = '.$products_id.'", $limit = 0, $null_values = false, $use_cache = false, $add_prefix = false); echo $modif_qte_a_recep.'<br>'; echo $products_id.'<br>'; return $update; /*avec le execute */ //echo $modif_qte_a_recep.'<br>'; /*$update = "UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '.$modif_qte_a_recep.' WHERE `id_product` = '.$products_id.'"; //echo $update; $execute = Db::getInstance()->execute($update); return $execute;*/ /* avec une procédure */ /*$drop_45 = Db::getInstance()->Execute("DROP PROCEDURE IF EXISTS `CMD_TMP_FOUR_UPDATE`"); $create_45 = Db::getInstance()->Execute("CREATE PROCEDURE `CMD_TMP_FOUR_UPDATE`() BEGIN UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '25' WHERE `id_product` = '16656'; END"); $procedure_45 = Db::getInstance()->Execute("CALL `CMD_TMP_FOUR_UPDATE`"); return $procedure_45;*/ } Edited February 16, 2017 by JoeSatriani (see edit history) Link to comment Share on other sites More sharing options...
coeos.pro Posted February 16, 2017 Share Posted February 16, 2017 Essaye Db::getInstance()->update('cmd_four'... Et fait le ménage dans ce qui suit, pas de = Link to comment Share on other sites More sharing options...
JoeSatriani Posted February 17, 2017 Author Share Posted February 17, 2017 private function Get_Update_Quantite_A_Receptionner($modif_qte_a_recep, $products_id) { # Exécution de la requête SQL $update = "UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '".$modif_qte_a_recep."' WHERE `id_product` = '".$products_id."'"; var_dump($update); $execute = Db::getInstance()->execute($update); var_dump($execute); return $execute; } Salut du coup je suis parti sur bien plus simple mais fonctionne toujours pas. J'ai fait un var_dump il me retourne sa : string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '108' WHERE `id_product` = '1722'' (length=87) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '0' WHERE `id_product` = '14837'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16560'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16536'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16511'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '2' WHERE `id_product` = '16520'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16566'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16293'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '0' WHERE `id_product` = '14722'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '0' WHERE `id_product` = '14672'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '3397'' (length=85) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16633'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16556'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16557'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16559'' (length=86) boolean true string 'UPDATE `tmp_cmd_four` SET `quantite_a_receptionner` = '1' WHERE `id_product` = '16561'' (length=86) boolean true 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