CodeIgniter Forums
Creating/Dropping triggers using Active Record - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6)
+--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19)
+--- Thread: Creating/Dropping triggers using Active Record (/showthread.php?tid=62324)



Creating/Dropping triggers using Active Record - jLinux - 07-02-2015

Hey guys, I have a script setup to modify a table name in a Database, and then to delete the associated triggers for it, and create new ones using the new table name. When I execute the commands manually, it works fine, but when I execute this CI code..

PHP Code:
$current_table 'Example_Table';

self::$db->query("DROP TRIGGER IF EXISTS {$current_table}_created_timestamp");
self::$db->query("DROP TRIGGER IF EXISTS {$current_table}_modified_timestamp");

$prefix 'Partition_';
$new_table 'tester_asdfasdf';

self::$db->query("CREATE TRIGGER {$new_table}_created_timestamp BEFORE INSERT ON {$prefix}{$new_table} FOR EACH ROW SET new.created = UNIX_TIMESTAMP(NOW())");
self::$db->query("CREATE TRIGGER {$new_table}_updated_timestamp BEFORE UPDATE ON {$prefix}{$new_table} FOR EACH ROW SET new.modified = UNIX_TIMESTAMP(NOW())"); 

I get the following error:
Code:
Error Number: 1235

This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'

CREATE TRIGGER tester_asdfasdf_updated_timestamp BEFORE UPDATE ON Partition_tester_asdfasdf FOR EACH ROW SET new.modified = UNIX_TIMESTAMP(NOW())

Then, when I go to delete the trigger manually via MySQL, I get a very odd error:

   

Any ideas? Ive never seen an error like this.. Thanks!