PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm coding the "Install" script for my OpenSource CMS and it's going quite well. Currently I'm coding the part that creates the MySQL Databases and adds the default data to them.
I'm not sure on how to do this, at first I though I could just do:
But them problem with this is that if any data contain in the mysql has a ";" then the SQL query will get cut in half ( For example & ) So this didn't work at all.
I have no Idea on how to do this, I spent like an hour in ##php but no one could really help me out. I also tried using exec() but I couldn't get that to work either =\
-Set autocommmit, unique_checks, foreign_key_checks to 0..
- And then load the data...
- then set foreign_key_checks and unique_checks to 1...
- source ./path/to/file
- commit
- set autocommit to 1...
But since i'm lazy i wrote a little bash script that does all this for you
AlexC,
Just copy the bash source file like 'restore.sh' and make it executable by chdmod 755 . Pass the arguements through PHP and use system function to execute that bash file.
This script depends on the fact that there is a mysql-client program available in the path.. This is an assumption that can be made true for most platforms
You can build the same string with php... And then call the mysql-client program from your php script...
In that case you can't use php... (Since php5 the mysql extension isn't enabled by default.. So it would be impossible to talk with a mysql dbms.. Might want to rethink your policy )
<Off-topic>What do you mean with 'XML would be the best way'? And what would be the dtd/xsd of the xml file?
In that case you can't use php... (Since php5 the mysql extension isn't enabled by default.. So it would be impossible to talk with a mysql dbms.. Might want to rethink your policy Wink)
MySQL is nearly always enabled but excution functions are quite often disabled and are also subject to other restrictions and of course the OS. The policy is fine.
AlexC_ do you have control of install/stage3/tables.sql, if you do why not change it to install/stage3/table.sql.php and put each separate query as a separate element of an array?