Jump to content

[SOLVED] DataBase query problems


Raullara

Recommended Posts

Hi Everyone, 

 

Im trying to do an update on ps_stock_available table, i'm doing it this way.

 

The first i do is read the xml file where i have the data i need

 

foreach ($xml->children() as $products) {
                    foreach ($products->children() as $product => $data) {
 
                        $id_product = $data->id_product;
                        $id_product_attribute = $data->id_product_subcategory;
                        $stock = $data->stock;
// STOCK DISPLAYS CORRECTLY
                        $output .= $this->displayConfirmation($this->l($stock));
 
// DATA DISPLAYS CORRECTLY
//                        $output .= $this->displayConfirmation($this->l($id_product));
//                        $output .= $this->displayConfirmation($this->l($id_product_attribute));
//                        $output .= $this->displayConfirmation($this->l($stock));
                        
// IS THE UPDATE EXECUTED CORRECTLY? my module do not crash
 
                          Db::getInstance()->update('ps_stock_available', array(
                              'quantity' => (int)$stock, 
                          ). 'WHERE id_product = ' . $id_product . 'AND id_product_attribute = ' . $id_product_attribute);
                    }
                }

 

Thanks a lot in advance

Edited by vekia (see edit history)
Link to comment
Share on other sites

and what you see in query outpur error message?

 

Okay, with the help of this console ( i wasn't using it , sorry about that, im pretty new on developing on prestashop) its okay
 
The problem was just the query, the name of the table was ps_ps_name, were 2 WHERE clauses etc. now works fine.
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...