diff --git a/htdocs/admin/system/mysql-tables-contraintes.php b/htdocs/admin/system/mysql-tables-contraintes.php
index 037b3ca8f95..02a3c97fbc3 100644
--- a/htdocs/admin/system/mysql-tables-contraintes.php
+++ b/htdocs/admin/system/mysql-tables-contraintes.php
@@ -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 '
';
print '
';
print '';
+if($base==1)
+{
print '| Tables | ';
print ''.$langs->trans("Type").' | ';
print 'Contraintes | ';
+}
+else
+{
+ print 'Contraintes | ';
+ print 'Type de la contrainte | ';
+}
print "
\n";
-$sql = "SHOW TABLE STATUS";
+
$result = $db->query($sql);
if ($result)
diff --git a/htdocs/admin/system/mysql-tables.php b/htdocs/admin/system/mysql-tables.php
index a8fed76dd11..648b5b9a90c 100644
--- a/htdocs/admin/system/mysql-tables.php
+++ b/htdocs/admin/system/mysql-tables.php
@@ -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 '
';
print '';
@@ -83,7 +88,46 @@ if ($result)
$i++;
}
}
-print '
';
+}
+else
+{
+print_titre("Tables Mysql");
+print '
';
+print '';
+print '';
+print '| Nom de la table | ';
+print 'Nombre de tuples lu | ';
+print 'Nb index fetcher. | ';
+print 'Nbre de tuples inserer | ';
+print 'Nbre de tuple modifier | ';
+print 'Nbre de tuple supprimer | ';
+print "
\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 "";
+ print '| '.$row[0].' | ';
+ print ''.$row[1].' | ';
+ print ''.$row[2].' | ';
+ print ''.$row[3].' | ';
+ print ''.$row[4].' | ';
+ print ''.$row[5].' | ';
+ print '
';
+ $i++;
+ }
+}
+print '
';
+}
llxFooter();
?>
diff --git a/htdocs/admin/system/mysql.php b/htdocs/admin/system/mysql.php
index 466713eafa6..7968d417082 100644
--- a/htdocs/admin/system/mysql.php
+++ b/htdocs/admin/system/mysql.php
@@ -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 '
';
print '';
@@ -36,7 +59,6 @@ print '| Propri
print ' | Valeur | ';
print "\n";
-$sql = "SHOW VARIABLES";
$result = $db->query($sql);
if ($result)
@@ -49,7 +71,10 @@ if ($result)
$objp = $db->fetch_object( $i);
$var=!$var;
print "";
- print '| '.$objp->Variable_name.' | '.$objp->Value.' | ';
+ if($base==1)
+ print ''.$objp->Variable_name.' | '.$objp->Value.' | ';
+ else
+ print ''.$objp->name.' | '.$objp->setting.' | ';
print '
';
$i++;
diff --git a/htdocs/lib/pgsql.lib.php b/htdocs/lib/pgsql.lib.php
index 2b1d446f4e4..c1d82271d7e 100644
--- a/htdocs/lib/pgsql.lib.php
+++ b/htdocs/lib/pgsql.lib.php
@@ -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.
diff --git a/htdocs/user.class.php b/htdocs/user.class.php
index 22eb3c24833..e2c2a9f2b24 100644
--- a/htdocs/user.class.php
+++ b/htdocs/user.class.php
@@ -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);