Reputation: 32104
I'm building a web application using PHP5.3 and Zend Framework 1.9.4. i have an sql file that creates and populates the relevant tables.
is there a way to install this sql file using PHP or even some component of Zend Framework ? for now i just search for the mysql client binary and install using it.
Upvotes: 0
Views: 286
Reputation: 11
for me it worked with explode(';',$string) then loop through resulted parts and after checking if trimmed version of the current part is not blank simply ran mysql_query() in a error catching construction (so i don't get that 'blank execution' error)
Upvotes: 1
Reputation: 690
Could you explain why parsing is not wanted? If your data is such that " ) ; \n
" or maybe just ") ;
" can be used as a delimiter string then you can read the entire file into a string ( file_get_contents ) and break into parts ( strtok ) in totally 3-4 lines.
( Or you could look at phpmyadmin source code if that is available to you, but that's very unwise to use like that )
Upvotes: 1
Reputation: 1307
For my Zend Framework projects, I do this using Ant's SQL task, so when I deploy the application using Ant, it runs the sql script to create the tables (if they don't exist). I think you could also do the same thing with phing, if you are familiar with that.
Sorry, that's not really a direct answer to your question, but if you use something like Ant it can get the job done for you.
Upvotes: 1