mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-03 23:52:24 +01:00
Fix: modification de la fonction DDLListTables car mysqli_list_tables n'existe plus sous mysqli
Fix: ajout vrification de l'existence des tables dans l'upgrade
This commit is contained in:
@@ -149,29 +149,33 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
'llx_telephonie_societe_ligne',
|
||||
'llx_telephonie_tarif_client');
|
||||
foreach ($listtables as $val)
|
||||
{
|
||||
$sql = "SHOW CREATE TABLE ".$val;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dolibarr_print_error($db);
|
||||
{
|
||||
$values=$db->fetch_array($resql);
|
||||
$i=0;
|
||||
$createsql=$values[1];
|
||||
while (eregi('CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`',$createsql,$reg) && $i < 100)
|
||||
{
|
||||
$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
|
||||
$resqldrop = $db->query($sqldrop);
|
||||
if ($resqldrop)
|
||||
{
|
||||
print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
|
||||
}
|
||||
$createsql=eregi_replace('CONSTRAINT `'.$reg[1].'`','XXX',$createsql);
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
|
||||
}
|
||||
{
|
||||
$searchTable = '';
|
||||
$searchTable = $db->DDLListTables($conf->db->name,$val);
|
||||
if ($searchTable == $val)
|
||||
{
|
||||
$sql = "SHOW CREATE TABLE ".$val;
|
||||
$resql = $db->query($sql);
|
||||
if (! $resql) dolibarr_print_error($db);
|
||||
{
|
||||
$values=$db->fetch_array($resql);
|
||||
$i=0;
|
||||
$createsql=$values[1];
|
||||
while (eregi('CONSTRAINT `(0_[0-9a-zA-Z]+|[_0-9a-zA-Z]+_ibfk_[0-9]+)`',$createsql,$reg) && $i < 100)
|
||||
{
|
||||
$sqldrop="ALTER TABLE ".$val." DROP FOREIGN KEY ".$reg[1];
|
||||
$resqldrop = $db->query($sqldrop);
|
||||
if ($resqldrop)
|
||||
{
|
||||
print '<tr><td colspan="2">'.$sqldrop.";</td></tr>\n";
|
||||
}
|
||||
$createsql=eregi_replace('CONSTRAINT `'.$reg[1].'`','XXX',$createsql);
|
||||
$i++;
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -672,15 +672,22 @@ class DoliDb
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Liste des tables dans une database.
|
||||
\param database Nom de la database
|
||||
\return resource
|
||||
*/
|
||||
function DDLListTables($database)
|
||||
{
|
||||
$this->results = mysql_list_tables($database, $this->db);
|
||||
return $this->results;
|
||||
}
|
||||
\brief Liste des tables dans une database.
|
||||
\param database Nom de la database
|
||||
\param table Nom de la table <20> rechercher
|
||||
\return resource
|
||||
*/
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
$like = '';
|
||||
if ($table) $like = "LIKE '".$table."'"
|
||||
$result = mysqli_query($this->db, "SHOW TABLES FROM ".$database." ".$like." ");
|
||||
while($row = mysqli_fetch_array($result))
|
||||
{
|
||||
$this->results = $row[0];
|
||||
}
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Cr<43>e une table
|
||||
|
||||
@@ -678,12 +678,19 @@ class DoliDb
|
||||
/**
|
||||
\brief Liste des tables dans une database.
|
||||
\param database Nom de la database
|
||||
\param table Nom de la table <20> rechercher
|
||||
\return resource
|
||||
*/
|
||||
function DDLListTables($database)
|
||||
function DDLListTables($database, $table='')
|
||||
{
|
||||
$this->results = mysqli_list_tables($database, $this->db);
|
||||
return $this->results;
|
||||
$like = '';
|
||||
if ($table) $like = "LIKE '".$table."'";
|
||||
$result = mysqli_query($this->db, "SHOW TABLES FROM ".$database." ".$like." ");
|
||||
while($row = mysqli_fetch_array($result))
|
||||
{
|
||||
$this->results = $row[0];
|
||||
}
|
||||
return $this->results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user