Description: This script will create tables and load data from an sql file.
Comment: (none)
Language: PHP Highlight Mode: PHP Last Modified: February 27th, 2009
<?PHPFUNCTION run_query_batch($handle,$filename=""){// Open SQL file.IF(!($fd=FOPEN($filename,"r"))){DIE("Failed to open $filename: ".MYSQL_ERROR()."<br>");}// Iterate through each line in the file.WHILE(!FEOF($fd)){// Read next line from file.$line=FGETS($fd,32768);$stmt="$stmt$line";// Semicolon indicates end of statement, keep adding to the statement.// until one is reached.IF(!PREG_MATCH("/;/",$stmt)){CONTINUE;}// Remove semicolon and execute entire statement.$stmt=PREG_REPLACE("/;/","",$stmt);// Execute the statement.MYSQL_QUERY($stmt,$handle)||DIE("Query failed: ".MYSQL_ERROR()."<br>");$stmt="";}// Close SQL file.FCLOSE($fd);}
run_query_batch($dbhandle,"schema.sql");?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.