Welcome Guest, Not a member yet? Register   Sign In
Creating/Dropping triggers using Active Record
#1

(This post was last modified: 07-02-2015, 08:40 PM by jLinux.)

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!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB