Jump to content

Update request doesn't work


Recommended Posts

Hello everybody,

 

I am trying to update a value in the database but unfortunately, my request isn't taken into account.

 

I checked and the program gets into the function and the conditions but only the update request isn't working.

 

Here is my code, it would be great if you could help me,

public function setActiveInactive($active, $id_product)

    {

       

        if($active==1)

        {            

            Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product p 

            LEFT JOIN '._DB_PREFIX_.'product_attribute a ON p.id_product = a.id_product

            SET p.active = 0

            WHERE a.id_product_attribute = '.(int)$id_product);

        }

        else if($active==0)

        {

            Tools::dieObject(0);

            Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product p 

            LEFT JOIN '._DB_PREFIX_.'product_attribute a ON p.id_product = a.id_product

            SET p.active = 1

            WHERE a.id_product_attribute = '.(int)$id_product);

        }

    }

Thank's a lot !

 

Kathleen

Share this post


Link to post
Share on other sites

Bonjour,

excusez-moi pour l'erreur de langue.

 

Je souhaiterais faire un update avec jointure. Mais ça ne fonctionne pas.

 

Le programme entre bien dans la condition, c'est la requête qui ne s'effectue pas.

 

Pourriez-vous me dire ce qui ne va pas avec ma requête d'update ?

 

Merci d'avance !

public function setActiveInactive($active, $id_product)

    {

       

        if($active==1)

        {            

            Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product p 

            LEFT JOIN '._DB_PREFIX_.'product_attribute a ON p.id_product = a.id_product

            SET p.active = 0

            WHERE a.id_product_attribute = '.(int)$id_product);

        }

        else if($active==0)

        {

            Tools::dieObject(0);

            Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product p 

            LEFT JOIN '._DB_PREFIX_.'product_attribute a ON p.id_product = a.id_product

            SET p.active = 1

            WHERE a.id_product_attribute = '.(int)$id_product);

        }

    }

 

Kathleen

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More