feof84 Posted September 30, 2012 Share Posted September 30, 2012 Hi, I wrote a function to launch when I have to delete a product. It 'correct? function delete_product($id_product) { $db = mysql_connect(host, user, password) or die("Connessione non riuscita: " . mysql_error()); mysql_select_db(database, $db) or die ("Impossibile connettersi al database database<br>"); /* elimino il prodotto dalla tab ps_product */ $q = "DELETE FROM `ps_product` WHERE `ps_product`.`id_product`=$id_product"; $result=mysql_query($q); if (!$result) { die('Invalid query: ' . mysql_error()); } /* elimino il prodotto dalla tab ps_category_product */ $q = "DELETE FROM `ps_category_product` WHERE `ps_category_product`.`id_product` =$id_product"; $result=mysql_query($q); if (!$result) { die('Invalid query: ' . mysql_error()); } /* elimino il prodotto dalla tab */ $q = "DELETE FROM `ps_product_lang` WHERE `ps_product_lang`.`id_product` =$id_product"; $result=mysql_query($q); if (!$result) { die('Invalid query: ' . mysql_error()); } /* elimino le immagini associate al prodotto */ $q = "DELETE FROM `ps_image` WHERE `ps_image`.`id_product` =$id_product"; $result=mysql_query($q); if (!$result) { die('Invalid query: ' . mysql_error()); } mysql_close($db); return TRUE; } Link to comment Share on other sites More sharing options...
CartExpert.net Posted October 1, 2012 Share Posted October 1, 2012 Hi. There are other product related tables too, like the attributes, tags, size etc. tables. You should rather use the Product class to delete a product. Regards. Robin. The CartExpert Team 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