I'm inserting an SQL Template in a new database through PHP code using the mysqli->multi_query()
function. This SQL Template contains something like:
CREATE TABLE `applicants` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_bin NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DELIMITER $$
CREATE FUNCTION `myFunctionExample`(`someField` INT(11), `someOtherField` VARCHAR(255) CHARSET utf8) RETURNS double(10,3)
BEGIN
.... MY SQL ....
RETURN ...;
END;
DELIMITER $$
CREATE FUNCTION `mySecondFunctionExample`(`someField` INT(11), `someOtherField` VARCHAR(255) CHARSET utf8) RETURNS double(10,3)
BEGIN
.... MY SQL ....
RETURN ...;
END;
I have two different problems:
When using PHP:
All the tables are created, no functions are created
When using PHPMyAdmin:
All the tables are created, only the first function is created
So it seems I have a problem separating the functions (?) and somehow mysqli->multi_query()
is not creating the functions?