1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 05:37:32 +02:00

check for existing tables during install.

This commit is contained in:
CaMer0n
2009-10-21 11:08:32 +00:00
parent 6497a639e0
commit e5afcd0aef

View File

@@ -9,9 +9,9 @@
* Installation file * Installation file
* *
* $Source: /cvs_backup/e107_0.8/install_.php,v $ * $Source: /cvs_backup/e107_0.8/install_.php,v $
* $Revision: 1.45 $ * $Revision: 1.46 $
* $Date: 2009-10-21 07:56:39 $ * $Date: 2009-10-21 11:08:32 $
* $Author: marj_nl_fr $ * $Author: e107coders $
* *
*/ */
@@ -1227,6 +1227,9 @@ class e_install
// Force UTF-8 again // Force UTF-8 again
$this->dbqry('SET NAMES `utf8`'); $this->dbqry('SET NAMES `utf8`');
$srch = array("CREATE TABLE","(");
$repl = array("DROP TABLE IF EXISTS","");
foreach ($result[0] as $sql_table) foreach ($result[0] as $sql_table)
{ {
// preg_match("/CREATE TABLE\s(.*?)\s\(/si", $sql_table, $match); // preg_match("/CREATE TABLE\s(.*?)\s\(/si", $sql_table, $match);
@@ -1234,6 +1237,12 @@ class e_install
// preg_match_all("/create(.*?)myisam;/si", $sql_data, $result ); // preg_match_all("/create(.*?)myisam;/si", $sql_data, $result );
$sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table); $sql_table = preg_replace("/create table\s/si", "CREATE TABLE {$this->previous_steps['mysql']['prefix']}", $sql_table);
// Drop existing tables before creating.
$tmp = explode("\n",$sql_table);
$drop_table = str_replace($srch,$repl,$tmp[0]);
$this->dbqry($drop_table);
if (!$this->dbqry($sql_table, $link)) if (!$this->dbqry($sql_table, $link))
{ {
return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>"); return nl2br(LANINS_061."\n\n<b>".LANINS_083."\n</b><i>".mysql_error($link)."</i>");