jeudi 31 janvier 2019

Mysql trigger run manually but not triggered by laravel Model insert method

I have made a simple trigger to increase the count of attributeset when any product is assigned into it. It works well when i create new product. But problem is that it do not trigger when i use the Laravel save method to insert a record.

Here is my trigger



CREATE TRIGGER `after_insert_product_count_in_attribute_set` AFTER 
INSERT ON `sbn_product` FOR EACH ROW BEGIN update 
`sbn_attribute_set` SET product_usage = product_usage + 1 where id 
= New.attribute_set_id; END


Here is my laravel code



    $product = new Product();
    $product->url = $url;  
    $product->auto_sku = $autosku;
    $product->created_by = $user_id;
    $product->updated_by = $user_id; 
    $product->price=10.15
    $product->save();




from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2TmSgZl
via IFTTT

Aucun commentaire:

Enregistrer un commentaire