mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
Fix: Support utf8 for database creation
Only option latin and utf8 are enabled.
This commit is contained in:
parent
b398463aaa
commit
b997c9c2cb
|
|
@ -215,12 +215,14 @@ class ModeleBoxes
|
|||
}
|
||||
}
|
||||
|
||||
// Complete line to max
|
||||
/*
|
||||
while ($i < $this->max)
|
||||
{
|
||||
$var=!$var;
|
||||
print '<tr '.$bcx[$var].'><td colspan="'.$nbcol.'"> </td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}*/
|
||||
|
||||
print "</table>\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ if (! $error)
|
|||
}
|
||||
//print $_POST["db_type"].",".$_POST["db_host"].",$userroot,$passroot,$databasefortest,".$_POST["db_port"];
|
||||
$db = new DoliDb($_POST["db_type"],$_POST["db_host"],$userroot,$passroot,$databasefortest,$_POST["db_port"]);
|
||||
|
||||
|
||||
dolibarr_syslog("databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected, LOG_DEBUG);
|
||||
//print "databasefortest=".$databasefortest." connected=".$db->connected." database_selected=".$db->database_selected;
|
||||
|
||||
|
|
@ -229,17 +229,21 @@ if (! $error && $db->connected)
|
|||
$listOfCharacterSet=$db->getListOfCharacterSet();
|
||||
$listOfCollation=$db->getListOfCollation();
|
||||
|
||||
// Choice of dolibarr_main_db_charaster_set
|
||||
// Choice of dolibarr_main_db_character_set
|
||||
?>
|
||||
<tr>
|
||||
<td valign="top" class="label"><?php echo $langs->trans("CharacterSetDatabase"); ?></td>
|
||||
<td valign="top" class="label"><?php
|
||||
if (sizeof($listOfCharacterSet))
|
||||
{
|
||||
print '<select name="dolibarr_main_db_charaster_set" '.$disabled.'>';
|
||||
print '<select name="dolibarr_main_db_character_set" '.$disabled.'>';
|
||||
$selected="";
|
||||
foreach ($listOfCharacterSet as $characterSet)
|
||||
{
|
||||
// We keep only utf8 and iso
|
||||
$linedisabled=false;
|
||||
if (! eregi('(utf8|latin1)',$characterSet['charset'])) $linedisabled=true;
|
||||
|
||||
if ($defaultCharacterSet == $characterSet['charset'] )
|
||||
{
|
||||
$selected="selected";
|
||||
|
|
@ -248,16 +252,16 @@ if (! $error && $db->connected)
|
|||
{
|
||||
$selected="";
|
||||
}
|
||||
print '<option value="'.$characterSet['charset'].'" '.$selected.'>'.$characterSet['charset'].' ('.$characterSet['description'].')</option>';
|
||||
print '<option value="'.$characterSet['charset'].'" '.$selected.($linedisabled?' disabled="true"':'').'>'.$characterSet['charset'].' ('.$characterSet['description'].')</option>';
|
||||
}
|
||||
print '</select>';
|
||||
if ($disabled=="disabled"){
|
||||
print '<input type="hidden" name="dolibarr_main_db_charaster_set" value="'.$defaultCharacterSet.'">';
|
||||
print '<input type="hidden" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="dolibarr_main_db_charaster_set" value="'.$defaultCharacterSet.'">';
|
||||
print '<input type="text" name="dolibarr_main_db_character_set" value="'.$defaultCharacterSet.'">';
|
||||
}
|
||||
?></td>
|
||||
<td class="label">
|
||||
|
|
@ -279,6 +283,10 @@ if (! $error && $db->connected)
|
|||
$selected="";
|
||||
foreach ($listOfCollation as $collation)
|
||||
{
|
||||
// We keep only utf8 and iso
|
||||
$linedisabled=false;
|
||||
if (! eregi('(utf8_general|latin1_swedish)',$collation['collation'])) $linedisabled=true;
|
||||
|
||||
if ($defaultCollationConnection == $collation['collation'])
|
||||
{
|
||||
$selected="selected";
|
||||
|
|
@ -287,7 +295,7 @@ if (! $error && $db->connected)
|
|||
{
|
||||
$selected="";
|
||||
}
|
||||
print '<option value="'.$collation['collation'].'" '.$selected.'>'.$collation['collation'].'</option>';
|
||||
print '<option value="'.$collation['collation'].'" '.$selected.($linedisabled?' disabled="true"':'').'>'.$collation['collation'].'</option>';
|
||||
}
|
||||
print '</select>';
|
||||
if ($disabled=="disabled"){
|
||||
|
|
|
|||
|
|
@ -81,11 +81,12 @@ if ($_POST["action"] == "set")
|
|||
{
|
||||
if (! eregi('^db_pass',$cle)) dolibarr_install_syslog("Choice for ".$cle." = ".$valeur);
|
||||
}
|
||||
|
||||
|
||||
// Show title of step
|
||||
print '<h3>'.$langs->trans("ConfigurationFile").'</h3>';
|
||||
print '<table cellspacing="0" width="100%" cellpadding="1" border="0">';
|
||||
|
||||
// Verification validite parametre main_dir
|
||||
// Check parameter main_dir
|
||||
if (! $error)
|
||||
{
|
||||
if (! is_dir($main_dir))
|
||||
|
|
@ -103,115 +104,22 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
}
|
||||
|
||||
// Sauvegarde fichier configuration
|
||||
if (! $error)
|
||||
{
|
||||
$fp = fopen("$conffile", "w");
|
||||
|
||||
if($fp)
|
||||
{
|
||||
clearstatcache();
|
||||
|
||||
fputs($fp, '<?php');
|
||||
fputs($fp,"\n");
|
||||
fputs($fp,"#\n");
|
||||
fputs($fp,"# File generated by Dolibarr installer on ".dolibarr_print_date(gmmktime(),''));
|
||||
fputs($fp,"\n");
|
||||
fputs($fp,"#\n");
|
||||
fputs($fp,"# Take a look at conf.php.example file for an example of conf.php file\n");
|
||||
fputs($fp,"# and explanations for all possibles parameters.\n");
|
||||
fputs($fp,"#\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_url_root="'.$_POST["main_url"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_document_root="'.$main_dir.'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_data_root="'.$main_data_dir.'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_host="'.$_POST["db_host"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_port="'.$_POST["db_port"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_name="'.$_POST["db_name"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_user="'.$_POST["db_user"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_pass="'.$_POST["db_pass"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_type="'.$_POST["db_type"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_character_set="'.$_POST["dolibarr_main_db_charaster_set"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_collation="'.$_POST["dolibarr_main_db_collation"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
/* Authentication */
|
||||
if ($_POST["db_type"] == 'mssql')
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr_mdb2";');
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr";');
|
||||
}
|
||||
fputs($fp,"\n");
|
||||
|
||||
/* Preparation integration SMARTY */
|
||||
fputs($fp, '$dolibarr_smarty_libs_dir="";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_smarty_compile="";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_smarty_cache="";');
|
||||
fputs($fp,"\n");
|
||||
/* Fin Smarty*/
|
||||
|
||||
fputs($fp, '?>');
|
||||
fclose($fp);
|
||||
|
||||
if (file_exists("$conffile"))
|
||||
{
|
||||
include("$conffile"); // On force rechargement. Ne pas mettre include_once !
|
||||
conf($dolibarr_main_document_root);
|
||||
|
||||
print "<tr><td>";
|
||||
print $langs->trans("SaveConfigurationFile");
|
||||
print "</td><td>";
|
||||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
// Chargement driver acces bases
|
||||
require_once($dolibarr_main_document_root."/lib/databases/".$dolibarr_main_db_type.".lib.php");
|
||||
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Creation des répertoires
|
||||
***************************************************************************/
|
||||
|
||||
// Creation des sous-répertoires main_data_dir
|
||||
// Chargement driver acces bases
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Directory '".$main_dir."' exists");
|
||||
|
||||
require_once($main_dir."/lib/databases/".$_POST["db_type"].".lib.php");
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
* Create directories
|
||||
***************************************************************************/
|
||||
|
||||
// Create subdirectory main_data_dir
|
||||
if (! $error)
|
||||
{
|
||||
// Répertoire des documents
|
||||
if (! is_dir($main_data_dir))
|
||||
{
|
||||
|
|
@ -277,8 +185,14 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
}
|
||||
|
||||
// Write conf file on disk
|
||||
if (! $error)
|
||||
{
|
||||
$error+=write_conf_file($conffile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Création des Bases de données
|
||||
* Create database and admin user database
|
||||
*/
|
||||
if (! $error)
|
||||
{
|
||||
|
|
@ -293,7 +207,7 @@ if ($_POST["action"] == "set")
|
|||
*/
|
||||
if (isset($_POST["db_create_user"]) && $_POST["db_create_user"] == "on")
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Creation de l'utilisateur: ".$dolibarr_main_db_user);
|
||||
dolibarr_install_syslog("etape1: Create database user: ".$dolibarr_main_db_user);
|
||||
|
||||
//print $conf->db->host." , ".$conf->db->name." , ".$conf->db->user." , ".$conf->db->port;
|
||||
$databasefortest=$conf->db->name;
|
||||
|
|
@ -382,23 +296,32 @@ if ($_POST["action"] == "set")
|
|||
|
||||
|
||||
/*
|
||||
* Si creation database demandée, on la crée
|
||||
* If database creation is asked, we create it
|
||||
*/
|
||||
if (! $error && (isset($_POST["db_create_database"]) && $_POST["db_create_database"] == "on"))
|
||||
{
|
||||
dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name);
|
||||
dolibarr_install_syslog("etape1: Create database : ".$dolibarr_main_db_name, LOG_DEBUG);
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$userroot,$passroot,'',$conf->db->port);
|
||||
|
||||
if ($db->connected)
|
||||
{
|
||||
|
||||
if ($db->DDLCreateDb($dolibarr_main_db_name))
|
||||
if ($db->DDLCreateDb($dolibarr_main_db_name, $dolibarr_main_db_character_set, $dolibarr_main_db_collation))
|
||||
{
|
||||
print '<tr><td>';
|
||||
print $langs->trans("DatabaseCreation").' : ';
|
||||
print $dolibarr_main_db_name;
|
||||
print '</td>';
|
||||
print "<td>".$langs->trans("OK")."</td></tr>";
|
||||
|
||||
$check1=$db->getDefaultCharacterSetDatabase();
|
||||
$check2=$db->getDefaultCollationDatabase();
|
||||
dolibarr_install_syslog('etape1: Note that default server was charset='.$check1.' collation='.$check2, LOG_DEBUG);
|
||||
|
||||
// If values differs, we save conf file again
|
||||
//if ($check1 != $dolibarr_main_db_character_set) dolibarr_install_syslog('etape1: Value for character_set is not the one asked for database creation', LOG_WARNING);
|
||||
//if ($check2 != $dolibarr_main_db_collation) dolibarr_install_syslog('etape1: Value for collation is not the one asked for database creation', LOG_WARNING);
|
||||
// TODO
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -445,7 +368,7 @@ if ($_POST["action"] == "set")
|
|||
*/
|
||||
if (! $error)
|
||||
{
|
||||
dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name);
|
||||
dolibarr_install_syslog("etape1: connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name, LOG_DEBUG);
|
||||
//print "connexion de type=".$conf->db->type." sur host=".$conf->db->host." port=".$conf->db->port." user=".$conf->db->user." name=".$conf->db->name;
|
||||
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name,$conf->db->port);
|
||||
|
|
@ -455,7 +378,7 @@ if ($_POST["action"] == "set")
|
|||
// si accès serveur ok et accès base ok, tout est ok, on ne va pas plus loin, on a même pas utilisé le compte root.
|
||||
if ($db->database_selected == 1)
|
||||
{
|
||||
dolibarr_install_syslog("etape1: la connexion au serveur par le user ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ServerConnection")." : ";
|
||||
print $dolibarr_main_db_host;
|
||||
|
|
@ -463,7 +386,7 @@ if ($_POST["action"] == "set")
|
|||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
|
||||
dolibarr_install_syslog("etape1: la connexion a la base : ".$conf->db->name.",par le user : ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: connexion to database : ".$conf->db->name.", by user : ".$conf->db->user." is ok", LOG_DEBUG);
|
||||
print "<tr><td>";
|
||||
print $langs->trans("DatabaseConnection")." : ";
|
||||
print $dolibarr_main_db_name;
|
||||
|
|
@ -475,7 +398,7 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
else
|
||||
{
|
||||
dolibarr_install_syslog("etape1: la connexion au serveur par le user ".$conf->db->user." est reussie");
|
||||
dolibarr_install_syslog("etape1: connexion to server by user ".$conf->db->user." is ok", LOG_DEBUG);
|
||||
print "<tr><td>";
|
||||
print $langs->trans("ServerConnection")." : ";
|
||||
print $dolibarr_main_db_host;
|
||||
|
|
@ -483,7 +406,7 @@ if ($_POST["action"] == "set")
|
|||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
|
||||
dolibarr_install_syslog("etape1: la connexion a la base ".$conf->db->name.",par le user ".$conf->db->user." a échoué");
|
||||
dolibarr_install_syslog("etape1: connexion to database ".$conf->db->name.", bu user : ".$conf->db->user." has failed", LOG_ERROR);
|
||||
print "<tr><td>";
|
||||
print $langs->trans("DatabaseConnection")." : ";
|
||||
print $dolibarr_main_db_name;
|
||||
|
|
@ -526,4 +449,113 @@ if ($_POST["action"] == "set")
|
|||
}
|
||||
|
||||
pFooter($error,$setuplang);
|
||||
|
||||
|
||||
/**
|
||||
* Save configuration file
|
||||
*/
|
||||
function write_conf_file($conffile)
|
||||
{
|
||||
global $conf,$langs;
|
||||
global $_POST,$main_dir,$main_data_dir;
|
||||
global $dolibarr_main_url_root,$dolibarr_main_document_root,$dolibarr_main_data_root,$dolibarr_main_db_host;
|
||||
global $dolibarr_main_db_port,$dolibarr_main_db_name,$dolibarr_main_db_user,$dolibarr_main_db_pass;
|
||||
global $dolibarr_main_db_type,$dolibarr_main_db_character_set,$dolibarr_main_db_collation,$dolibarr_main_authentication;
|
||||
global $dolibarr_smarty_libs_dir,$dolibarr_smarty_compile,$dolibarr_smarty_cache;
|
||||
|
||||
$error=0;
|
||||
|
||||
$fp = fopen("$conffile", "w");
|
||||
if($fp)
|
||||
{
|
||||
clearstatcache();
|
||||
|
||||
fputs($fp, '<?php');
|
||||
fputs($fp,"\n");
|
||||
fputs($fp,"#\n");
|
||||
fputs($fp,"# File generated by Dolibarr installer on ".dolibarr_print_date(gmmktime(),''));
|
||||
fputs($fp,"\n");
|
||||
fputs($fp,"#\n");
|
||||
fputs($fp,"# Take a look at conf.php.example file for an example of conf.php file\n");
|
||||
fputs($fp,"# and explanations for all possibles parameters.\n");
|
||||
fputs($fp,"#\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_url_root="'.$_POST["main_url"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_document_root="'.$main_dir.'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_data_root="'.$main_data_dir.'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_host="'.$_POST["db_host"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_port="'.$_POST["db_port"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_name="'.$_POST["db_name"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_user="'.$_POST["db_user"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_pass="'.$_POST["db_pass"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_type="'.$_POST["db_type"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_character_set="'.$_POST["dolibarr_main_db_character_set"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_main_db_collation="'.$_POST["dolibarr_main_db_collation"].'";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
/* Authentication */
|
||||
if ($_POST["db_type"] == 'mssql')
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr_mdb2";');
|
||||
}
|
||||
else
|
||||
{
|
||||
fputs($fp, '$dolibarr_main_authentication="dolibarr";');
|
||||
}
|
||||
fputs($fp,"\n");
|
||||
|
||||
/* Preparation integration SMARTY */
|
||||
fputs($fp, '$dolibarr_smarty_libs_dir="";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_smarty_compile="";');
|
||||
fputs($fp,"\n");
|
||||
|
||||
fputs($fp, '$dolibarr_smarty_cache="";');
|
||||
fputs($fp,"\n");
|
||||
/* Fin Smarty*/
|
||||
|
||||
fputs($fp, '?>');
|
||||
fclose($fp);
|
||||
|
||||
if (file_exists("$conffile"))
|
||||
{
|
||||
include("$conffile"); // On force rechargement. Ne pas mettre include_once !
|
||||
conf($dolibarr_main_document_root);
|
||||
|
||||
print "<tr><td>";
|
||||
print $langs->trans("SaveConfigurationFile");
|
||||
print "</td><td>";
|
||||
print $langs->trans("OK");
|
||||
print "</td></tr>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -707,13 +707,15 @@ class DoliDb
|
|||
}
|
||||
|
||||
/**
|
||||
\brief Cr<EFBFBD>ation d'une nouvelle base de donn<EFBFBD>e
|
||||
\param database nom de la database <EFBFBD> cr<EFBFBD>er
|
||||
\return resource resource d<EFBFBD>finie si ok, null si k
|
||||
\remarks Ne pas utiliser les fonctions xxx_create_db (xxx=mssql, ...) car elles sont deprecated
|
||||
On force creation de la base avec le charset forcecharset
|
||||
*/
|
||||
function DDLCreateDb($database)
|
||||
* \brief Create a new database
|
||||
* \param database Database name to create
|
||||
* \param charset Charset used to store data
|
||||
* \param collation Charset used to sort data
|
||||
* \return resource resource defined if OK, null if KO
|
||||
* \remarks Ne pas utiliser les fonctions xxx_create_db (xxx=mssql, ...) car elles sont deprecated
|
||||
* On force creation de la base avec le charset forcecharset
|
||||
*/
|
||||
function DDLCreateDb($database,$charset='',$collation='')
|
||||
{
|
||||
// ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci
|
||||
$sql = 'CREATE DATABASE '.$database;
|
||||
|
|
|
|||
|
|
@ -697,15 +697,20 @@ class DoliDb
|
|||
/**
|
||||
* \brief Create a new database
|
||||
* \param database Database name to create
|
||||
* \param charset Charset used to store data
|
||||
* \param collation Charset used to sort data
|
||||
* \return resource resource defined if OK, null if KO
|
||||
* \remarks Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
|
||||
* We force to create database with charset this->forcecharset and collate this->forcecollate
|
||||
*/
|
||||
function DDLCreateDb($database)
|
||||
function DDLCreateDb($database,$charset='',$collation='')
|
||||
{
|
||||
if (empty($charset)) $charset=$this->forcecharset;
|
||||
if (empty($collation)) $collation=$this->collation;
|
||||
|
||||
// ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci
|
||||
$sql = 'CREATE DATABASE '.$database;
|
||||
$sql.= ' DEFAULT CHARACTER SET '.$this->forcecharset.' DEFAULT COLLATE '.$this->forcecollate;
|
||||
$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation;
|
||||
|
||||
dolibarr_syslog($sql,LOG_DEBUG);
|
||||
$ret=$this->query($sql);
|
||||
|
|
@ -714,6 +719,7 @@ class DoliDb
|
|||
// We try again for compatibility with Mysql < 4.1.1
|
||||
$sql = 'CREATE DATABASE '.$database;
|
||||
$ret=$this->query($sql);
|
||||
dolibarr_syslog($sql,LOG_DEBUG);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -711,15 +711,20 @@ class DoliDb
|
|||
/**
|
||||
* \brief Create a new database
|
||||
* \param database Database name to create
|
||||
* \return resource resource defined if OK, null if KO
|
||||
* \param charset Charset used to store data
|
||||
* \param collation Charset used to sort data
|
||||
* \return resource resource defined if OK, null if KO
|
||||
* \remarks Do not use function xxx_create_db (xxx=mysql, ...) as they are deprecated
|
||||
* We force to create database with charset this->forcecharset and collate this->forcecollate
|
||||
*/
|
||||
function DDLCreateDb($database)
|
||||
function DDLCreateDb($database,$charset='',$collation='')
|
||||
{
|
||||
if (empty($charset)) $charset=$this->forcecharset;
|
||||
if (empty($collation)) $collation=$this->collation;
|
||||
|
||||
// ALTER DATABASE dolibarr_db DEFAULT CHARACTER SET latin DEFAULT COLLATE latin1_swedish_ci
|
||||
$sql = 'CREATE DATABASE '.$database;
|
||||
$sql.= ' DEFAULT CHARACTER SET '.$this->forcecharset.' DEFAULT COLLATE '.$this->forcecollate;
|
||||
$sql.= ' DEFAULT CHARACTER SET '.$charset.' DEFAULT COLLATE '.$collation;
|
||||
|
||||
dolibarr_syslog($sql,LOG_DEBUG);
|
||||
$ret=$this->query($sql);
|
||||
|
|
@ -728,6 +733,7 @@ class DoliDb
|
|||
// We try again for compatibility with Mysql < 4.1.1
|
||||
$sql = 'CREATE DATABASE '.$database;
|
||||
$ret=$this->query($sql);
|
||||
dolibarr_syslog($sql,LOG_DEBUG);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -798,14 +798,19 @@ class DoliDb
|
|||
|
||||
|
||||
/**
|
||||
\brief Cr<EFBFBD>ation d'une nouvelle base de donn<EFBFBD>e
|
||||
\param database nom de la database <EFBFBD> cr<EFBFBD>er
|
||||
\return resource resource d<EFBFBD>finie si ok, null si ko
|
||||
\remarks Ne pas utiliser les fonctions xxx_create_db (xxx=mysql, ...) car elles sont deprecated
|
||||
*/
|
||||
function DDLCreateDb($database)
|
||||
* \brief Create a new database
|
||||
* \param database Database name to create
|
||||
* \param charset Charset used to store data
|
||||
* \param collation Charset used to sort data
|
||||
* \return resource resource defined if OK, null if KO
|
||||
* \remarks Ne pas utiliser les fonctions xxx_create_db (xxx=mysql, ...) car elles sont deprecated
|
||||
*/
|
||||
function DDLCreateDb($database,$charset='',$collation='')
|
||||
{
|
||||
$ret=$this->query('CREATE DATABASE '.$database.' OWNER '.$this->db_user.' ENCODING \''.$this->forcecharset.'\' ;');
|
||||
if (empty($charset)) $charset=$this->forcecharset;
|
||||
if (empty($collation)) $collation=$this->collation;
|
||||
|
||||
$ret=$this->query('CREATE DATABASE '.$database.' OWNER '.$this->db_user.' ENCODING \''.$charset.'\' ;');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user