Thanks very much for the previous help...
Basking in the SUN of my new found happiness, now that I have a non- crashing and fully functional Firefox/phpMyAdmin DUO, after sadly parting from a long friendship with Safari...
I created a table via the phpMyAdmin GUI (NOT using the SQL window), with the following structure.
------------------------------------------------------ CREATE TABLE `mvc_project_01`.`telephones` ( `id` INT NOT NULL AUTO_INCREMENT, `fk_users_id` INT NOT NULL COMMENT 'Users Foreign Key', `location` VARCHAR(30) NOT NULL, `country_code` VARCHAR(4) NOT NULL, `area` VARCHAR(5) NOT NULL, `number` VARCHAR(8) NOT NULL, `created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP, `modified_by` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB; ------------------------------------------------------
after saving the table, I clicked on [Create PHP Code] button, and it generated the correct php :
------------------------------------------------------ $sql = "CREATE TABLE `mvc_project_01`.`telephones` (`id` INT NOT NULL AUTO_INCREMENT, `fk_users_id` INT NOT NULL COMMENT 'Users Foreign Key ', `location` VARCHAR(30) NOT NULL, `country_code` VARCHAR(4) NOT NULL, `area` VARCHAR(5) NOT NULL, `number` VARCHAR(8) NOT NULL, `created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`)) ENGINE = InnoDB;"; ------------------------------------------------------
I copied the text to BBEdit,and replaced every ',', with ',\n', and made a couple of other minor adjustments, which makes the php easier to read :
------------------------------------------------------ $sql = " CREATE TABLE `mvc_project_01`.`telephones` ( `id` INT NOT NULL AUTO_INCREMENT, `fk_users_id` INT NOT NULL COMMENT 'Users Foreign Key', `location` VARCHAR(30) NOT NULL, `country_code` VARCHAR(4) NOT NULL, `area` VARCHAR(5) NOT NULL, `number` VARCHAR(8) NOT NULL, `created` TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `modified` TIMESTAMP on update CURRENT_TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', `modified_by` VARCHAR(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE = InnoDB; "; ------------------------------------------------------
I didn't know how to add the trigger via the phpMyAdmin GUI, so I decided to use the SQL window.
I put the following Trigger Definition in the SQL window, after creating the table :
------------------------------------------------------ DROP TRIGGER IF EXISTS `mvc_project_01`.`telephones_insert_trigger`; DELIMITER ;; CREATE TRIGGER `mvc_project_01`.`telephones_insert_trigger` BEFORE INSERT ON `mvc_project_01`.`telephones` FOR EACH ROW BEGIN SET NEW.created = NOW(); SET NEW.modified = NOW(); END; ;; DELIMITER ; ------------------------------------------------------
Everything went well, phpMyDamin was happy, but when I clicked on [Create PHP Code] the result below was not what I had expected :
------------------------------------------------------ $sql = "# MySQL returned an empty result set (i.e. zero rows).\n" . "\n" . "DELIMITER ;\n" . ""; ------------------------------------------------------
Any Ideas what I might be doing wrong ?
Thank You Very Much...
Bill Hernandez Plano, Texas
Everything went well, phpMyDamin was happy, but when I clicked on [Create PHP Code] the result below was not what I had expected :
$sql = "# MySQL returned an empty result set (i.e. zero rows).\n" . "\n" . "DELIMITER ;\n" . "";
Any Ideas what I might be doing wrong ?
The interesting thing is that if you look at the structure for the table prior to entering any records, and :
( 1 ) I click on the "Details..." link at the bottom of the page ( 2 ) I can see the "telephones_insert_trigger" I had just entered via the SQL window. ( 3 ) I click on the pencil icon, and there's my TRIGGER in a SQL Query window... ( 4 ) I look it over, and am happy to see how easy this will be to modify, but I just click on the [GO] button ( 5 ) Now I see the phMyAdmin green happy message : Your SQL query has been executed successfully ( 6 ) Below that I see :
----------------------------------------------- DROP TRIGGER IF EXISTS `mvc_project_01`.`telephones_insert_trigger`//# MySQL returned an empty result set (i.e. zero rows). CREATE TRIGGER `mvc_project_01`.`telephones_insert_trigger` BEFORE INSERT ON `mvc_project_01`.`telephones` FOR EACH ROW BEGIN SET NEW.created = NOW(); SET NEW.modified = NOW(); END //# MySQL returned an empty result set (i.e. zero rows). -----------------------------------------------
( 7 ) Now I click on [Create PHP Code] again, but this time I get the expected results, shown below :
Showing as PHP code ----------------------------------------------- $sql = "DROP TRIGGER IF EXISTS `mvc_project_01`.`telephones_insert_trigger`//# MySQL returned an empty result set (i.e. zero rows).\n" . "\n" . "CREATE TRIGGER `mvc_project_01`.`telephones_insert_trigger` BEFORE INSERT ON `mvc_project_01`.`telephones`\n" . " FOR EACH ROW BEGIN\n" . " SET NEW.created = NOW();\n" . " SET NEW.modified = NOW();\n" . " END\n" . "//# MySQL returned an empty result set (i.e. zero rows).\n" . ""; -----------------------------------------------
So it appears as though when you first create the trigger and click on [Create PHP Code] you only get :
----------------------------------------------- $sql = "# MySQL returned an empty result set (i.e. zero rows).\n" . "\n" . "DELIMITER ;\n" . ""; -----------------------------------------------
But once you edit the trigger, save it, and click on [Create PHP Code] a second time you get the expected answer...
Thank You...
Bill Hernandez Plano, Texas