Update: [Background info: I'm working on a Silverlight app which uses PHP code to interact with the MySql dbase. I have a regular installation package on www.mobilesportscoach.com (demo site on www.mobilesportscoach.com/test) which works well when you run the SQL file in phpMyAdmin. But I want the whole package to be installable in Joomla without having people to run several scripts in several places.]
I'm creating an joomla components xml install file and in the install section I want it to create my tables / stored procedures with an sql script so I've tried:
<install>
<sql>
<file charset="utf8" driver="mysql">install.sql</file>
</sql>
<install>
Tables aren't the problem, single line sql code runs fine but in my SQL create procedure statements I have to change the delimiter (that's how it works in MySQL), e.g:
DELIMITER $$
CREATE PROCEDURE `tp_delete_match_and_scores_onmatchid`(IN matchid VARCHAR(10))
BEGIN
DELETE FROM tp_scores WHERE (tp_scores.matchid=matchid);
DELETE FROM tp_matches WHERE (tp_matches.recid=matchid);
END$$
DELIMITER ;
The extension installer gives me:
JInstaller: :Install: Error SQL DB function failed with error number 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL
server version for the right syntax to use near 'DELIMITER $$
I've also tried the custom installer api but I can't get it to work: I have an installfile tag in my xml: install.component.php
My php:
<?php
function com_install(){
global $database;
echo "TEST COM_INSTALL";
//get database
if(defined('_JEXEC')){
//joomla 1.5
$database = JFactory::getDBO();
}
//table for item index
$query = "CREATE PROCEDURE `tp_delete_match_and_scores_onmatchid`(IN matchid VARCHAR(10)";
$query .= "\nBEGIN";
$query .= "\nDELETE FROM tp_scores WHERE (tp_scores.matchid=matchid);";
$query .= "\nDELETE FROM tp_matches WHERE (tp_matches.recid=matchid);";
$query .= "\nEND";
$database->setQuery($query);
$database->query();
?>
The component installs alright but I can't find my procedure with phpMyAdmin / is not created. Seems like the install.component.php isn't fired at all?
I don't want users to run a separate sql script, I want it all in one package if possible...