suite des adaptations pour postgresql
This commit is contained in:
parent
226df401dd
commit
97e60e5759
@ -20,24 +20,42 @@
|
||||
* $Source$
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
include_once $dolibarr_main_document_root."/lib/${dolibarr_main_db_type}.lib.php";
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
if($dolibarr_main_db_type=="mysql")
|
||||
{
|
||||
print_titre("Tables Mysql - Contraintes");
|
||||
|
||||
$sql = "SHOW TABLE STATUS";
|
||||
$base=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_titre("Tables PostreSql - Contraintes");
|
||||
$sql = "select conname,contype from pg_constraint;";
|
||||
$base=2;
|
||||
}
|
||||
print '<br>';
|
||||
print '<table class="noborder" cellpadding="4" cellspacing="1">';
|
||||
print '<tr class="liste_titre">';
|
||||
if($base==1)
|
||||
{
|
||||
print '<td>Tables</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td>Contraintes</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td>Contraintes</td>';
|
||||
print '<td>Type de la contrainte</td>';
|
||||
}
|
||||
print "</tr>\n";
|
||||
|
||||
$sql = "SHOW TABLE STATUS";
|
||||
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
|
||||
@ -20,10 +20,12 @@
|
||||
* $Source$
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
include_once $dolibarr_main_document_root."/lib/${dolibarr_main_db_type}.lib.php";
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
|
||||
if ($_GET["action"] == 'convert')
|
||||
{
|
||||
@ -31,8 +33,11 @@ if ($_GET["action"] == 'convert')
|
||||
}
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_titre("Tables Mysql");
|
||||
|
||||
if($dolibarr_main_db_type=="mysql")
|
||||
{
|
||||
|
||||
print_titre("Tables Mysql");
|
||||
|
||||
print '<br>';
|
||||
print '<table class="noborder" cellpadding="4" cellspacing="1">';
|
||||
@ -83,7 +88,46 @@ if ($result)
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
print_titre("Tables Mysql");
|
||||
print '<br>';
|
||||
print '<table class="noborder" cellpadding="4" cellspacing="1">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>Nom de la table</td>';
|
||||
print '<td>Nombre de tuples lu</td>';
|
||||
print '<td>Nb index fetcher.</td>';
|
||||
print '<td>Nbre de tuples inserer</td>';
|
||||
print '<td>Nbre de tuple modifier</td>';
|
||||
print '<td>Nbre de tuple supprimer</td>';
|
||||
print "</tr>\n";
|
||||
$sql = "select relname,seq_tup_read,idx_tup_fetch,n_tup_ins,n_tup_upd,n_tup_del
|
||||
from pg_stat_user_tables;";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$num = $db->num_rows();
|
||||
$var=True;
|
||||
$i=0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($i);
|
||||
$var=!$var;
|
||||
print "<TR $bc[$var]>";
|
||||
print '<td align="right">'.$row[0].'</td>';
|
||||
print '<td align="right">'.$row[1].'</td>';
|
||||
print '<td align="right">'.$row[2].'</td>';
|
||||
print '<td align="right">'.$row[3].'</td>';
|
||||
print '<td align="right">'.$row[4].'</td>';
|
||||
print '<td align="right">'.$row[5].'</td>';
|
||||
print '</tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
llxFooter();
|
||||
?>
|
||||
|
||||
@ -21,13 +21,36 @@
|
||||
*/
|
||||
require("./pre.inc.php");
|
||||
|
||||
//include "/home/vegeta/www/dolibarr/htdocs/conf/conf.php";
|
||||
// ici comme ça j'ai la style sheet!
|
||||
|
||||
/*$conf = "../../conf/conf.php";
|
||||
if (file_exists($conf))
|
||||
{
|
||||
include($conf);
|
||||
}*/
|
||||
|
||||
include_once $dolibarr_main_document_root."/lib/${dolibarr_main_db_type}.lib.php";
|
||||
|
||||
|
||||
|
||||
if (!$user->admin)
|
||||
accessforbidden();
|
||||
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_titre("Configuration Mysql");
|
||||
if($dolibarr_main_db_type=="mysql")
|
||||
{
|
||||
print_titre("Configuration MySql");
|
||||
$sql = "SHOW VARIABLES";
|
||||
$base=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print_titre("Configuration Pgsql");
|
||||
$sql = "select name,setting from pg_settings;";
|
||||
$base=2;
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print '<table class="noborder" cellpadding="3" cellspacing="1">';
|
||||
@ -36,7 +59,6 @@ print '<td>Propri
|
||||
print '<td>Valeur</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$sql = "SHOW VARIABLES";
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
@ -49,7 +71,10 @@ if ($result)
|
||||
$objp = $db->fetch_object( $i);
|
||||
$var=!$var;
|
||||
print "<tr $bc[$var]>";
|
||||
print '<td>'.$objp->Variable_name.'</td><td>'.$objp->Value.'</td>';
|
||||
if($base==1)
|
||||
print '<td>'.$objp->Variable_name.'</td><td>'.$objp->Value.'</td>';
|
||||
else
|
||||
print '<td>'.$objp->name.'</td><td>'.$objp->setting.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
@ -471,10 +471,13 @@ class DoliDb
|
||||
\return id
|
||||
*/
|
||||
|
||||
function last_insert_id()
|
||||
function last_insert_id($tab)
|
||||
{
|
||||
return pg_last_oid($this->results);
|
||||
}
|
||||
$result = pg_query($this->db,"select max(rowid) from ".$tab." ;");
|
||||
$nbre=pg_num_rows($result);
|
||||
$row = pg_fetch_result($result,0,0);
|
||||
return $row;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief obtient le nombre de lignes affectées dans la précédente opération.
|
||||
|
||||
@ -484,8 +484,8 @@ class User
|
||||
{
|
||||
if ($this->db->num_rows())
|
||||
{
|
||||
$obj = $this->db->fetch_object($result , 0);
|
||||
|
||||
//$obj = $this->db->fetch_object($result , 0);
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
$this->nom = stripslashes($obj->name);
|
||||
$this->prenom = stripslashes($obj->firstname);
|
||||
@ -579,8 +579,8 @@ class User
|
||||
*/
|
||||
function create()
|
||||
{
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->login'";
|
||||
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->login';";
|
||||
//$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->email';";
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
@ -593,16 +593,23 @@ class User
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user (datec, login) values (now(),'$this->login')";
|
||||
$sql = "insert into ".MAIN_DB_PREFIX."user (datec,login,email)
|
||||
values(now(),'$this->login','$this->email');";
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
if ($this->db->affected_rows())
|
||||
/*if ($this->db->affected_rows())
|
||||
{
|
||||
$this->id = $this->db->last_insert_id();
|
||||
$this->update();
|
||||
$this->set_default_rights();
|
||||
return $this->id;
|
||||
}
|
||||
}*/ // ce code pose probleme en postgres il est remplace par le bloc ci dessous
|
||||
// fonctionne autant en postgres que mysql
|
||||
$table = "".MAIN_DB_PREFIX."user";
|
||||
$this->id = $this->db->last_insert_id($table);
|
||||
$this->set_default_rights();
|
||||
$this->update();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -614,7 +621,7 @@ class User
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
} //fin function
|
||||
|
||||
/**
|
||||
* \brief Créé en base un utilisateur depuis l'objetc contact
|
||||
@ -629,7 +636,6 @@ class User
|
||||
|
||||
$this->login = strtolower(substr($contact->prenom, 0, 3)) . strtolower(substr($contact->nom, 0, 3));
|
||||
|
||||
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->login'";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@ -719,12 +725,18 @@ class User
|
||||
*/
|
||||
function update()
|
||||
{
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->login' AND rowid <> $this->id";
|
||||
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='$this->login' AND rowid <> $this->id;";
|
||||
|
||||
|
||||
$sql = "SELECT login FROM ".MAIN_DB_PREFIX."user WHERE login ='bennybe' AND
|
||||
email = '$this->id';";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$this->db->free();
|
||||
|
||||
|
||||
if ($num)
|
||||
{
|
||||
@ -747,7 +759,8 @@ class User
|
||||
$sql .= ", module_compta = 1";
|
||||
$sql .= ", code = '$this->code'";
|
||||
$sql .= ", note = '$this->note'";
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
$sql .= " WHERE rowid = $this->id;";
|
||||
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user