0

I have a website built with codeigniter
In phpmyadmin i have created this trigger

CREATE TRIGGER `After_Add_Order` AFTER INSERT ON `order`
 FOR EACH ROW BEGIN
IF (NEW.points IS NOT NULL) THEN
update users set users.points = users.points + new.points where users.user_id = new.owner_id;
END IF;
END

when i insert data in phpmyadmin the trigger get fired but when i insert data within php the trigger doesn't fire even though the points within inserted order has value.

and this is my php code

if ($this->db->insert('order', $data)) {
   $id = $this->db->insert_id();
   return $id;
}


Any help

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
Snatch
  • 27
  • 2
  • 7
  • Please don't try execute trigger on php . its bad practice [See more](https://stackoverflow.com/questions/1467369/invoking-a-php-script-from-a-mysql-trigger) – Imran Jan 08 '18 at 11:22
  • the trigger in phpmyadmin not in php – Snatch Jan 08 '18 at 11:24
  • In `$data`, can you confirm that `points` is not null? – Warren Jan 08 '18 at 12:46
  • yes it's inserted in the database with the right value – Snatch Jan 08 '18 at 13:00
  • Double-check that your app is connecting to the same MySQL instance that phpMyAdmin is connecting to. You may have created the trigger in one MySQL instance, but not the one your app is using. – Bill Karwin Jan 16 '18 at 17:32

0 Answers0