forked from Wavyzz/dolibarr
Qual: More portable SQL
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/install/etape2.php
|
||||
\ingroup install
|
||||
\brief Cree les tables, cles primaires, cles etrangeres, index et fonctions en base puis charge les donnees de reference
|
||||
\version $Id$
|
||||
* \file htdocs/install/etape2.php
|
||||
* \ingroup install
|
||||
* \brief Cree les tables, cles primaires, cles etrangeres, index et fonctions en base puis charge les donnees de reference
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
include("./inc.php");
|
||||
@@ -289,8 +289,8 @@ if ($_POST["action"] == "set")
|
||||
else
|
||||
{
|
||||
print "<tr><td>".$langs->trans("CreateOtherKeysForTable",$name);
|
||||
print "<br>".$langs->trans("Request").' '.$requestnb.' : '.$buffer;
|
||||
print "</td>";
|
||||
print "<br>\n".$langs->trans("Request").' '.$requestnb.' : '.$db->lastqueryerror();
|
||||
print "\n</td>";
|
||||
print "<td>".$langs->trans("Error")." ".$db->errno()." ".$db->error()."</td></tr>";
|
||||
$error++;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ if ($_POST["action"] == "set")
|
||||
|
||||
// Creation donnees
|
||||
$handle=opendir($dir);
|
||||
dolibarr_install_syslog("Ouverture repertoire ".$dir." handle=".$handle,LOG_DEBUG);
|
||||
dolibarr_install_syslog("Ouverture repertoire data ".$dir." handle=".$handle,LOG_DEBUG);
|
||||
while (($file = readdir($handle))!==false)
|
||||
{
|
||||
if (preg_match('/\.sql$/i',$file) && preg_match('/^llx_/i',$file))
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_co_exp.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_co_exp.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_co_exp ADD INDEX idx_co_exp_fk_commande (fk_commande);
|
||||
ALTER TABLE llx_co_exp ADD INDEX idx_co_exp_fk_expedition (fk_expedition);
|
||||
@@ -23,8 +23,5 @@ create table llx_co_exp
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_expedition integer NOT NULL,
|
||||
|
||||
key(fk_commande),
|
||||
key(fk_expedition)
|
||||
fk_expedition integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_co_fa.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_co_fa.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_co_fa ADD INDEX idx_co_fa_fk_commande (fk_commande);
|
||||
ALTER TABLE llx_co_fa ADD INDEX idx_co_fa_fk_facture (fk_facture);
|
||||
@@ -22,8 +22,5 @@ create table llx_co_fa
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_facture integer NOT NULL,
|
||||
|
||||
key(fk_commande),
|
||||
key(fk_facture)
|
||||
fk_facture integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_co_liv.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_co_liv.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_co_liv ADD INDEX idx_co_liv_fk_commande (fk_commande);
|
||||
ALTER TABLE llx_co_liv ADD INDEX idx_co_liv_fk_livraison (fk_livraison);
|
||||
@@ -23,8 +23,5 @@ create table llx_co_liv
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_commande integer NOT NULL,
|
||||
fk_livraison integer NOT NULL,
|
||||
|
||||
key(fk_commande),
|
||||
key(fk_livraison)
|
||||
fk_livraison integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_co_pr.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_co_pr.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_co_pr ADD INDEX idx_co_pr_fk_commande (fk_commande);
|
||||
ALTER TABLE llx_co_pr ADD INDEX idx_co_pr_fk_propale (fk_propale);
|
||||
24
htdocs/install/mysql/tables/llx_pr_exp.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_pr_exp.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_pr_exp ADD INDEX idx_pr_exp_fk_propal (fk_propal);
|
||||
ALTER TABLE llx_pr_exp ADD INDEX idx_pr_exp_fk_expedition (fk_expedition);
|
||||
@@ -23,8 +23,5 @@ create table llx_pr_exp
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_propal integer NOT NULL,
|
||||
fk_expedition integer NOT NULL,
|
||||
|
||||
key(fk_propal),
|
||||
key(fk_expedition)
|
||||
fk_expedition integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
24
htdocs/install/mysql/tables/llx_pr_liv.key.sql
Normal file
24
htdocs/install/mysql/tables/llx_pr_liv.key.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2008 Regis Houssin <regis@dolibarr.fr>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_pr_liv ADD INDEX idx_pr_liv_fk_propal (fk_propal);
|
||||
ALTER TABLE llx_pr_liv ADD INDEX idx_pr_liv_fk_livraison (fk_livraison);
|
||||
@@ -23,8 +23,5 @@ create table llx_pr_liv
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_propal integer NOT NULL,
|
||||
fk_livraison integer NOT NULL,
|
||||
|
||||
key(fk_propal),
|
||||
key(fk_livraison)
|
||||
fk_livraison integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
21
htdocs/install/mysql/tables/llx_societe_commerciaux.key.sql
Normal file
21
htdocs/install/mysql/tables/llx_societe_commerciaux.key.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- ===================================================================
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation; either version 2 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program; if not, write to the Free Software
|
||||
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
--
|
||||
-- $Id$
|
||||
-- ===================================================================
|
||||
|
||||
ALTER TABLE llx_societe_commerciaux ADD UNIQUE INDEX uk_societe_commerciaux (fk_soc, fk_user);
|
||||
@@ -1,5 +1,6 @@
|
||||
-- ========================================================================
|
||||
-- Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
--
|
||||
-- This program is free software; you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
@@ -22,8 +23,6 @@ create table llx_societe_commerciaux
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_soc integer,
|
||||
fk_user integer,
|
||||
|
||||
UNIQUE INDEX(fk_soc, fk_user)
|
||||
fk_user integer
|
||||
)type=innodb;
|
||||
|
||||
|
||||
@@ -20,8 +20,10 @@
|
||||
-- ===========================================================================
|
||||
|
||||
|
||||
-- Supprimme orhpelins pour permettre mont<6E>e de la cl<63>
|
||||
-- Supprimme orhpelins pour permettre mont<6E>e de la cl<63>
|
||||
-- V4 DELETE llx_user_rights FROM llx_user_rights LEFT JOIN llx_user ON llx_user_rights.fk_user = llx_user.rowid WHERE llx_user.rowid IS NULL;
|
||||
|
||||
|
||||
ALTER TABLE llx_user_rights ADD CONSTRAINT fk_user_rights_fk_user_user FOREIGN KEY (fk_user) REFERENCES llx_user (rowid);
|
||||
|
||||
ALTER TABLE llx_user_rights ADD UNIQUE INDEX uk_user_rights (fk_user, fk_id);
|
||||
|
||||
@@ -22,8 +22,6 @@ create table llx_user_rights
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_user integer NOT NULL,
|
||||
fk_id integer NOT NULL,
|
||||
|
||||
UNIQUE INDEX(fk_user,fk_id)
|
||||
fk_id integer NOT NULL
|
||||
)type=innodb;
|
||||
|
||||
|
||||
@@ -161,7 +161,8 @@ class DoliDb
|
||||
return $line;
|
||||
}
|
||||
if ($line != "")
|
||||
{ # we are inside create table statement so lets process datatypes
|
||||
{
|
||||
# we are inside create table statement so lets process datatypes
|
||||
if (preg_match('/(ISAM|innodb)/i',$line)) { # end of create table sequence
|
||||
$line=preg_replace('/\)[\s\t]*type=(MyISAM|innodb);/i',');',$line);
|
||||
$line=preg_replace('/\)[\s\t]*engine=(MyISAM|innodb);/i',');',$line);
|
||||
@@ -172,20 +173,7 @@ class DoliDb
|
||||
$line=preg_replace('/[\s\t]*([a-zA-Z_0-9]*)[\s\t]*.*int.*auto_increment[^,]*/i','\\1 SERIAL PRIMARY KEY',$line);
|
||||
}
|
||||
|
||||
# int type conversion
|
||||
/* } elsif (/(\w*)int\(\d+\)/i) {
|
||||
$size=$1;
|
||||
$size =~ tr [A-Z] [a-z];
|
||||
if ($size eq "tiny" || $size eq "small") {
|
||||
$out = "int2";
|
||||
} elsif ($size eq "big") {
|
||||
$out = "int8";
|
||||
} else {
|
||||
$out = "int4";
|
||||
}
|
||||
s/\w*int\(\d+\)/$out/g;
|
||||
}
|
||||
*/
|
||||
# tinyint type conversion
|
||||
$line=str_replace('tinyint','smallint',$line);
|
||||
|
||||
# nuke unsigned
|
||||
@@ -223,78 +211,22 @@ class DoliDb
|
||||
$line=preg_replace('/^float/i','numeric',$line);
|
||||
$line=preg_replace('/(\s*)float/i','\\1numeric',$line);
|
||||
|
||||
# unique key(field1,field2)
|
||||
/* if (/unique key\s*\((\w+\s*,\s*\w+)\)/i) {
|
||||
s/unique key\s*\((\w+\s*,\s*\w+)\)/UNIQUE\($1\)/i;
|
||||
$create_sql.=$_;
|
||||
next;
|
||||
}
|
||||
*/
|
||||
# unique index(field1,field2)
|
||||
if (preg_match('/unique index\s*\((\w+\s*,\s*\w+)\)/i',$line))
|
||||
{
|
||||
$line=preg_replace('/unique index\s*\((\w+\s*,\s*\w+)\)/i','UNIQUE\(\\1\)',$line);
|
||||
}
|
||||
# unique key [name] (field)
|
||||
/* if (/unique key\s*(\w*)\s*\((\w+)\)/i) {
|
||||
s/unique key\s*(\w*)\s*\((\w+)\)/UNIQUE\($2\)/i;
|
||||
my $idxname=($1?"$1":"idx_${table}_$2");
|
||||
$create_sql.=$_;
|
||||
$create_index .= "CREATE INDEX $idxname ON $table ($2);\n";
|
||||
next;
|
||||
|
||||
# alter table create [unique] index (field1, field2 ...)
|
||||
# ALTER TABLE llx_accountingaccount ADD INDEX idx_accountingaccount_fk_pcg_version (fk_pcg_version)
|
||||
if (preg_match('/ALTER\s*TABLE\s*(.*)\s*ADD\s*(UNIQUE)?\s*(INDEX)?\s*(.*)\s*\(([\w,\s]+)\)/i',$line,$reg))
|
||||
{
|
||||
$fieldlist=$reg[5];
|
||||
$idxname=$reg[4];
|
||||
$tablename=$reg[1];
|
||||
$line = "-- ".$line." replaced by --\n";
|
||||
$line.= "CREATE ".($reg[2]?$reg[2].' ':'')."INDEX ".$idxname." ON ".$tablename." (".$fieldlist.")";
|
||||
}
|
||||
*/
|
||||
# unique index [name] (field)
|
||||
/* if (/unique index\s*(\w*)\s*\((\w+)\)/i) {
|
||||
s/unique index\s*(\w*)\s*\((\w+)\)/UNIQUE\($2\)/i;
|
||||
my $idxname=($1?"$1":"idx_${table}_$2");
|
||||
$create_sql.=$_;
|
||||
$create_index .= "CREATE INDEX $idxname ON $table ($2);\n";
|
||||
next;
|
||||
}
|
||||
*/
|
||||
# unique (field) et unique (field1, field2 ...)
|
||||
/* if (/unique\s*\(([\w,\s]+)\)/i) {
|
||||
s/unique\s*\(([\w,\s]+)\)/UNIQUE\($1\)/i;
|
||||
my $fieldlist="$1";
|
||||
my $idxname="idx_${table}_${fieldlist}";
|
||||
$idxname =~ s/\W/_/g; $idxname =~ tr/_/_/s;
|
||||
$create_sql.=$_;
|
||||
$create_index .= "CREATE INDEX $idxname ON $table ($fieldlist);\n";
|
||||
next;
|
||||
}
|
||||
*/
|
||||
# index(field)
|
||||
/* if (/index\s*(\w*)\s*\((\w+)\)/i) {
|
||||
my $idxname=($1?"$1":"idx_${table}_$2");
|
||||
$create_index .= "CREATE INDEX $idxname ON $table ($2);\n";
|
||||
next;
|
||||
}
|
||||
*/
|
||||
# primary key
|
||||
/* if (/\bkey\b/i && !/^\s+primary key\s+/i) {
|
||||
s/KEY(\s+)[^(]*(\s+)/$1 UNIQUE $2/i; # hack off name of the non-primary key
|
||||
}
|
||||
*/
|
||||
# key(xxx)
|
||||
/* if (/key\s*\((\w+)\)/i) {
|
||||
my $idxname="idx_${table}_$1";
|
||||
$create_index .= "CREATE INDEX $idxname ON $table ($1);\n";
|
||||
next;
|
||||
}
|
||||
*/
|
||||
# Quote column names
|
||||
/* s/(^\s*)([^\s\-\(]+)(\s*)/$1"$2"$3/gi if (!/\bkey\b/i);
|
||||
*/
|
||||
# Remap colums with names of existing system attribute
|
||||
/* if (/"oid"/i) {
|
||||
s/"oid"/"_oid"/g;
|
||||
print STDERR "WARNING: table $table uses column \"oid\" which is renamed to \"_oid\"\nYou should fix application manually! Press return to continue.";
|
||||
my $wait=<STDIN>;
|
||||
}
|
||||
s/oid/_oid/i if (/key/i && /oid/i); # fix oid in key
|
||||
$create_sql.=$_;
|
||||
*/
|
||||
} # END of if ($create_sql ne "") i.e. were inside create table statement so processed datatypes
|
||||
else { # not inside create table
|
||||
#---- fix data in inserted data: (from MS world)
|
||||
@@ -503,7 +435,7 @@ class DoliDb
|
||||
$this->lasterror = $this->error();
|
||||
$this->lasterrno = $this->errno();
|
||||
//print "\n>> ".$query."<br>\n";
|
||||
//print '>> '.$this->lasterrno.' - '.$this->lasterror.' - '.$this->laqtqueryerror."<br>\n";
|
||||
//print '>> '.$this->lasterrno.' - '.$this->lasterror.' - '.$this->lastqueryerror."<br>\n";
|
||||
}
|
||||
$this->lastquery=$query;
|
||||
$this->results = $ret;
|
||||
@@ -758,7 +690,7 @@ class DoliDb
|
||||
1051 => 'DB_ERROR_NOSUCHTABLE',
|
||||
1054 => 'DB_ERROR_NOSUCHFIELD',
|
||||
1060 => 'DB_ERROR_COLUMN_ALREADY_EXISTS',
|
||||
1061 => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
|
||||
'42710' => 'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
|
||||
1062 => 'DB_ERROR_RECORD_ALREADY_EXISTS',
|
||||
'42704' => 'DB_ERROR_SYNTAX',
|
||||
'42601' => 'DB_ERROR_SYNTAX',
|
||||
@@ -786,30 +718,14 @@ class DoliDb
|
||||
$errno=$errorcode?$errorcode:$errorlabel;
|
||||
return ($errno?'DB_ERROR_'.$errno:'0');
|
||||
}
|
||||
|
||||
// TODO Virer cela
|
||||
if (empty($error_regexps))
|
||||
{
|
||||
$error_regexps = array(
|
||||
'/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => 'DB_ERROR_NOSUCHTABLE',
|
||||
'/table [\"\'].*[\"\'] does not exist/' => 'DB_ERROR_NOSUCHTABLE',
|
||||
'/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => 'DB_ERROR_RECORD_ALREADY_EXISTS',
|
||||
'/divide by zero$/' => 'DB_ERROR_DIVZERO',
|
||||
'/pg_atoi: error in .*: can\'t parse /' => 'DB_ERROR_INVALID_NUMBER',
|
||||
'/ttribute [\"\'].*[\"\'] not found$|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => 'DB_ERROR_NOSUCHFIELD',
|
||||
'/parser: parse error at or near \"/' => 'DB_ERROR_SYNTAX',
|
||||
'/referential integrity violation/' => 'DB_ERROR_CONSTRAINT'
|
||||
);
|
||||
}
|
||||
print 'WW'.pg_last_error($this->db).'WW';
|
||||
$valerror=pg_last_error($this->db);
|
||||
foreach ($error_regexps as $regexp => $code) {
|
||||
if (preg_match($regexp,$valerror)) {
|
||||
return $code;
|
||||
}
|
||||
}
|
||||
$errno=$valerror;
|
||||
return ($errno?'DB_ERROR':'0');
|
||||
// '/(Table does not exist\.|Relation [\"\'].*[\"\'] does not exist|sequence does not exist|class ".+" not found)$/' => 'DB_ERROR_NOSUCHTABLE',
|
||||
// '/table [\"\'].*[\"\'] does not exist/' => 'DB_ERROR_NOSUCHTABLE',
|
||||
// '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => 'DB_ERROR_RECORD_ALREADY_EXISTS',
|
||||
// '/divide by zero$/' => 'DB_ERROR_DIVZERO',
|
||||
// '/pg_atoi: error in .*: can\'t parse /' => 'DB_ERROR_INVALID_NUMBER',
|
||||
// '/ttribute [\"\'].*[\"\'] not found$|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => 'DB_ERROR_NOSUCHFIELD',
|
||||
// '/parser: parse error at or near \"/' => 'DB_ERROR_SYNTAX',
|
||||
// '/referential integrity violation/' => 'DB_ERROR_CONSTRAINT'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user