- This topic is empty.
-
AuthorPosts
-
-
March 20, 2006 at 2:21 am #9548sloppyboyMember
Hello,
I'm wondering if there is any possible way to take the structure/data export .sql files that SQLYog generates and read/execute it as a script via PHP code. Is this possible?
If this is not possible, I would find it VERY helpful if a feature was added to SQLYog Enterprise that would allow you to export the db structure and/or data into a php file that you could run from your php server.
I realize that you can import the .sql files from SQLYog into the db but I'm trying to build an installation script for an application that will be installed on many different web servers. And as far as I know, in php you have to execute one statement at a time which will be a HUGE headache if I have to strip each statement separately out of the .sql file and execute it individually.
Any ideas are appreciated. Thanks!
Tommy
-
March 20, 2006 at 8:54 am #20920peterlaursenParticipantQUOTE… into a php file that you could run from your php server
What you need is then to generate a PHP statment like
CODE$goforit = mysql_query('here goes 1st query') or die (mysql_error());$goforit = mysql_query('here goes 2st query') or die (mysql_error());
etc …
Now if you 'search and replace' the SQL generated by SQLyog in an editor and replace
CODE;with
CODE;') or die (mysql_error());$goforit = mysql_query('
it will be 95%. You will need to add the connection string and edit first and last statement. But it is a reasonably good idea of yours I think. One more export option: 'export as PHP-script'.
-
March 22, 2006 at 4:13 pm #20921sloppyboyMember
Thanks for your reply. I think for now I'm going to write a script that parses through a directory of .sql files generated by SQLYog and throws each individual statement into an array to be executed on the db in the right order.
This way I'll be able to generate multiple .sql files from SQLYog, put them in a single directory, and the script will be able to pick them up in sequential order, parse through them, and apply all sql statements in the right order. This is going to be useful for dropping hotfix db schema updates for an application where you would have multiple .sql files based on bug fixes or schema changes in between application releases.
Tommy
-
March 22, 2006 at 5:54 pm #20922RiteshMember
This is a nice idea.
In the meantime, you can use my_strtok() function available in SQLyogTunnel.php for tokenising the queries.
-
-
AuthorPosts
- You must be logged in to reply to this topic.