>
Parse mysql dump using PHP
Welcome, Guest

by Narendra on Friday, 14 November 2008
Parse mysql dump using PHP


Here is a function that would parse mysql dump and execute it. function parse_mysql_dump($url,$nowhost,$nowdatabase,$nowuser,$nowpass){ $link1 = mysql_connect($nowhost, $nowuser, $nowpass); if (!$link1) { die('Not connected : ' . mysql_error()); } // make foo the current db $db_selected = mysql_select_db($nowdatabase, $link1); if (!$db_selected) { die ('Can't use foo : ' .mysql_error()); } $content = file_get_contents($url); // Processing the SQL file content $file_content = explode("n",$content); $query = ""; foreach($file_content as $sql_line){ if(trim($sql_line) != "" && strpos($sql_line, "--") === false){ $query .= $sql_line; // Checking whether the line is a valid statement if(preg_match("/(.*);/", $sql_line)) { $query = substr($query, 0, strlen($query)-1); //Executing the parsed string, returns the error code in failure $result = mysql_query($query)or die(mysql_error().$query); $query = ""; } } } }



Blogger Image
My Blog Title

Product Engineering, software engineering company, Product Development, Product Migration, Product Re-engineering, Product Maintenance, Product Testing Commercial Application Development, Business Software development, commercial software for startups, Application Support and Maintenance, software testing Product Maintenance, Outsource product maintenance, product support and maintenance Product Migration, Product Re-engineering, product re-engineering services Product Research, Product Engineering, UI Prototyping Services Software Testing Services, Quality Assurance services, professional software testers, Load Testing, Functional Testing, Cross Platform, Browser Testing, Test Automation, Testing Tools, software quality analysis Functional Testing Services, software quality analysis, Software Testing Services, Application Testing Services, Functional Testing Types Automated Testing, Automated Testing Services, automation testing, test script development, Automation Test Tools, outsource automation testing Load Testing, Performance Testing Services, Load Testing Tools Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering Benefits of IT Outsourcing, Offshore Software Development companies, offshore software development firms Outsource planning, IT outsourcing, IT development services, offshore IT companies, offshore software development Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering Offshore Software Development, Outsource software services, offshore outsourcing services, offshore software development services, IT outsourcing services, software quality assurance services, Offshore IT services, Custom Application Development Services, Offshore Product Engineering