Changeset 512 for trunk/phpbms/install
- Timestamp:
- 04/22/09 13:40:06 (3 years ago)
- Location:
- trunk/phpbms/install
- Files:
-
- 2 modified
-
installajax.php (modified) (2 diffs)
-
install_include.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/phpbms/install/installajax.php
r495 r512 87 87 88 88 //Run create table sql file ocreate the tables 89 $tempReturn = $installer-> createTables("createtables.sql");89 $tempReturn = $installer->processSQLFile("createtables.sql"); 90 90 91 91 if($tempReturn !== true) … … 319 319 320 320 //Run create table sql file ocreate the tables 321 $tempReturn = $installer-> createTables($this->pathToModule.$this->createTablesSQL);321 $tempReturn = $installer->processSQLfile($this->pathToModule.$this->createTablesSQL); 322 322 323 323 if($tempReturn !== true) -
trunk/phpbms/install/install_include.php
r485 r512 11 11 12 12 13 function createTables($sqlfile){13 function processSQLfile($sqlfile){ 14 14 15 $sqlstatement=""; 16 $thereturn = ""; 17 $line = 1; 15 $return = ""; 18 16 19 $file Pointer = @ fopen($sqlfile,"r");17 $fileReturn = $this->db->processSQLFile($sqlfile); 20 18 21 if(!$filePointer) 22 return "Could not open SQL file: ".$sqlfile; 19 if(count($fileReturn->errors)){ 23 20 24 while(!feof($filePointer)) { 21 foreach($fileReturn->errors as $error) 22 $return = "\n\n".$error; 25 23 26 $ createstatement .= @ fgets($filePointer,1024);24 $return = substr($return, 2); 27 25 28 if(strpos($createstatement,";")){26 return $return; 29 27 30 $this->db->query(trim($createstatement)); 31 32 if($this->db->error) 33 return "Error creating tables on line ".$line.": ".$this->db->error." SQL Statement: ".trim($createstatement); 34 35 $createstatement = ""; 36 37 }//end if; 38 39 $line++; 40 41 }//end while 42 43 return true; 44 45 }//end function createTables 46 47 48 function processSQLfile($filename){ 49 50 $thefile = @ fopen($filename,"r"); 51 $line = 1; 52 $thereturn = ""; 53 54 if(!$thefile) 55 return "Could not open the SQL file ".$filename; 56 57 while(!feof($thefile)) { 58 59 $sqlstatement .= @ trim(fgets($thefile)); 60 61 // we look for the ; at the end of the line 62 // If it is not there, we keep adding to the sql statement 63 if(strrpos($sqlstatement,";") == strlen($sqlstatement)-1){ 64 65 $this->db->query(trim($sqlstatement)); 66 if($this->db->error) 67 $thereturn .= "Error processing SQL file '".$filename."' on line ".$line.": ".$this->db->error." - SQL Statement: ".$sqlstatement."\n"; 68 69 $sqlstatement = ""; 70 71 }//end if; 72 73 $line++; 74 75 }//end while 76 77 if($thereturn) 78 return $thereturn; 79 else 28 } else 80 29 return true; 81 30 82 }//end function 31 }//end function processSQLfile 83 32 84 33 }//end class