Source for file sqlload.php

Documentation is available at sqlload.php

  1. <?php
  2. /**
  3. * Load an SQL stream into the database
  4. *
  5. @author    Stuart Prescott
  6. @copyright  Copyright Stuart Prescott
  7. @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  8. @version    $Id$
  9. @package    Bumblebee
  10. @subpackage Installer
  11. */
  12.  
  13. /**
  14. * Load the generated SQL into the database one command at a time
  15. */
  16. function loadSQL($sql$host$username$passwd{
  17.   #echo "Loading SQL";
  18.   if ($connection mysql_pconnect($host$username$passwd)) {
  19.     // then we successfully logged on to the database
  20.     $sqllist preg_split('/;/'$sql);
  21.     foreach ($sqllist as $q{
  22.       #echo "$q\n";
  23.       if (preg_match('/^\s*$/'$q)) continue;
  24.       $handle mysql_query($q);
  25.       if ($handle{
  26.         return "ERROR: I had trouble executing SQL statement:"
  27.               ."<blockquote>$q</blockquote>"
  28.               ."MySQL said:<blockquote>"
  29.               .mysql_error()
  30.               ."</blockquote>";
  31.       }
  32.     }
  33.     return "SQL file loaded correctly";
  34.   else {
  35.     return "ERROR: Could not log on to database to load SQL file: ".mysql_error(;
  36.   }
  37. }
  38.  
  39. ?>

Documentation generated on Tue, 06 Mar 2007 10:02:00 +0000 by phpDocumentor 1.3.0