cvs: php4 /pear/DB common.php fbsql.php mssql.php mysql.php oci8.php odbc.php pgsql.php
| From: | Stig Bakken | Date: | Sat, 02 Feb 2002 00:27:47 +0000 |
| Subject: | cvs: php4 /pear/DB common.php fbsql.php mssql.php mysql.php oci8.php odbc.php pgsql.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-2275@lists.php.net to get a copy of this message | ||
ssb Fri Feb 1 19:27:47 2002 EDT
Modified files:
/php4/pear/DB common.php fbsql.php mssql.php mysql.php oci8.php
odbc.php pgsql.php
Log:
* the actual name of the sequences or sequence emulation tables may
now be configured with the "seqname_format" option
Index: php4/pear/DB/common.php diff -u php4/pear/DB/common.php:1.78 php4/pear/DB/common.php:1.79 --- php4/pear/DB/common.php:1.78 Sat Jan 19 02:46:24 2002 +++ php4/pear/DB/common.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.78 2002/01/19 07:46:24 cox Exp $ +// $Id: common.php,v 1.79 2002/02/02 00:27:47 ssb Exp $ // // Base class for DB implementations. // @@ -95,7 +95,8 @@ var $options = array( 'persistent' => false, 'optimize' => 'performance', - 'debug' => 0 + 'debug' => 0, + 'seqname_format' => '%s_seq' ); /** @@ -1247,6 +1248,15 @@ } return $this->getCol($sql); // Launch this query } + // }}} + // {{{ getSequenceName() + + function getSequenceName($sqn) + { + return sprintf($this->getOption("seqname_format"), + preg_replace('/[^a-z0-9_]/i', '_', $sqn)); + } + // }}} } Index: php4/pear/DB/fbsql.php diff -u php4/pear/DB/fbsql.php:1.12 php4/pear/DB/fbsql.php:1.13 --- php4/pear/DB/fbsql.php:1.12 Tue Dec 11 10:31:15 2001 +++ php4/pear/DB/fbsql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.12 2001/12/11 15:31:15 sebastian Exp $ +// $Id: fbsql.php,v 1.13 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's FrontBase // extension. @@ -424,7 +424,8 @@ $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); $repeat = 0; do { - $result = $this->query("INSERT INTO ${sqn}_seq VALUES(NULL)"); + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + $result = $this->query("INSERT INTO ${seqname} VALUES(NULL)"); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { $repeat = 1; @@ -448,7 +449,8 @@ function createSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq ". + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + return $this->query("CREATE TABLE ${seqname} ". '(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'. ' PRIMARY KEY(id))'); } @@ -459,7 +461,8 @@ function dropSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq RESTRICT"); + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + return $this->query("DROP TABLE ${seqname} RESTRICT"); } // }}} Index: php4/pear/DB/mssql.php diff -u php4/pear/DB/mssql.php:1.38 php4/pear/DB/mssql.php:1.39 --- php4/pear/DB/mssql.php:1.38 Thu Dec 27 07:06:50 2001 +++ php4/pear/DB/mssql.php Fri Feb 1 19:27:47 2002 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.38 2001/12/27 12:06:50 cox Exp $ +// $Id: mssql.php,v 1.39 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's Microsoft SQL Server // extension. @@ -292,11 +292,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("INSERT INTO ${sqn}_seq (vapor) VALUES (0)"); + $result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)"); $this->popErrorHandling(); if ($ondemand && DB::isError($result) && ($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE)) @@ -307,7 +307,7 @@ return $result; } } else { - $result = $this->query("SELECT @@IDENTITY FROM ${sqn}_seq"); + $result = $this->query("SELECT @@IDENTITY FROM $seqname"); $repeat = 0; } } while ($repeat); @@ -323,8 +323,8 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq". + $seqname = $this->getSequenceName($seq_name); + return $this->query("CREATE TABLE $seqname ". '([id] [int] IDENTITY (1, 1) NOT NULL ,' . '[vapor] [int] NULL)'); } @@ -333,8 +333,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP TABLE $seqname"); } // }}} Index: php4/pear/DB/mysql.php diff -u php4/pear/DB/mysql.php:1.85 php4/pear/DB/mysql.php:1.86 --- php4/pear/DB/mysql.php:1.85 Tue Jan 29 15:55:20 2002 +++ php4/pear/DB/mysql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.85 2002/01/29 20:55:20 chagenbu Exp $ +// $Id: mysql.php,v 1.86 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's MySQL // extension. @@ -479,13 +479,13 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { // XXX HACK: temporarily force error mode to "return" $tmp = $this->_default_error_mode; $this->_default_error_mode = PEAR_ERROR_RETURN; - $result = $this->query("UPDATE ${sqn}_seq ". + $result = $this->query("UPDATE ${seqname} ". 'SET id=LAST_INSERT_ID(id+1)'); $this->_default_error_mode = $tmp; if ($ondemand && DB::isError($result) && @@ -508,7 +508,7 @@ // Obtain a user-level lock... this will release any previous // application locks, but unlike LOCK TABLES, it does not abort // the current transaction and is much less frequently used. - $result = $this->getOne("SELECT GET_LOCK('${sqn}_seq_lock',10)"); + $result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); if (DB::isError($result)) { return $result; } @@ -518,13 +518,13 @@ return $this->mysqlRaiseError(1100); } - $highest_id = $this->getOne("SELECT MAX(id) FROM ${sqn}_seq"); + $highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}"); if (DB::isError($highest_id)) { return $highest_id; } // We should probably do something if $highest_id isn't // numeric, but I'm at a loss as how to handle that... - $result = $this->query("DELETE FROM ${sqn}_seq ". + $result = $this->query("DELETE FROM ${seqname} ". "WHERE id <> $highest_id"); if (DB::isError($result)) { return $result; @@ -533,7 +533,7 @@ // If another thread has been waiting for this lock, // it will go thru the above procedure, but will have no // real effect - $result = $this->getOne("SELECT RELEASE_LOCK('${sqn}_seq_lock')"); + $result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')"); if (DB::isError($result)) { return $result; } @@ -556,15 +556,15 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - $res = $this->query("CREATE TABLE ${sqn}_seq ". + $seqname = $this->getSequenceName($seq_name); + $res = $this->query("CREATE TABLE ${seqname} ". '(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'. ' PRIMARY KEY(id))'); if (DB::isError($res)) { return $res; } // insert yields value 1, nextId call will generate ID 2 - return $this->query("INSERT INTO ${sqn}_seq VALUES(0)"); + return $this->query("INSERT INTO ${seqname} VALUES(0)"); } // }}} @@ -572,8 +572,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP TABLE ${seqname}"); } // }}} Index: php4/pear/DB/oci8.php diff -u php4/pear/DB/oci8.php:1.44 php4/pear/DB/oci8.php:1.45 --- php4/pear/DB/oci8.php:1.44 Tue Jan 29 08:40:53 2002 +++ php4/pear/DB/oci8.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: oci8.php,v 1.44 2002/01/29 13:40:53 ssb Exp $ +// $Id: oci8.php,v 1.45 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's Oracle 8 // call-interface extension. @@ -576,11 +576,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->expectError(DB_ERROR_NOSUCHTABLE); - $result = $this->query("SELECT ${sqn}_seq.nextval FROM dual"); + $result = $this->query("SELECT ${seqname}.nextval FROM dual"); $this->popExpect(); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { @@ -605,8 +605,8 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("CREATE SEQUENCE ${seqname}"); } // }}} @@ -614,8 +614,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP SEQUENCE ${seqname}"); } // }}} Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.51 php4/pear/DB/odbc.php:1.52 --- php4/pear/DB/odbc.php:1.51 Fri Jan 18 11:28:15 2002 +++ php4/pear/DB/odbc.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: odbc.php,v 1.51 2002/01/18 16:28:15 cox Exp $ +// $Id: odbc.php,v 1.52 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's ODBC // extension. @@ -357,10 +357,10 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { - $result = $this->query("update ${sqn}_seq set id = id + 1"); + $result = $this->query("update ${seqname} set id = id + 1"); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOT_FOUND) { $repeat = 1; @@ -368,7 +368,7 @@ if (DB::isError($result)) { return $result; } - $result = $this->query("insert into ${sqn}_seq (id) values(0)"); + $result = $this->query("insert into ${seqname} (id) values(0)"); } else { $repeat = 0; } @@ -378,7 +378,7 @@ return $result; } - $result = $this->query("select id from ${sqn}_seq"); + $result = $this->query("select id from ${seqname}"); if (DB::isError($result)) { return $result; } @@ -397,7 +397,7 @@ function createSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq ". + return $this->query("CREATE TABLE ${seqname} ". '(id bigint NOT NULL,'. ' PRIMARY KEY(id))'); } Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.63 php4/pear/DB/pgsql.php:1.64 --- php4/pear/DB/pgsql.php:1.63 Thu Jan 17 06:31:12 2002 +++ php4/pear/DB/pgsql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.63 2002/01/17 11:31:12 cox Exp $ +// $Id: pgsql.php,v 1.64 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's PostgreSQL // extension. @@ -491,11 +491,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("SELECT NEXTVAL('${sqn}_seq')"); + $result = $this->query("SELECT NEXTVAL('${seqname}')"); $this->popErrorHandling(); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { @@ -528,9 +528,9 @@ */ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("CREATE SEQUENCE ${sqn}_seq"); + $result = $this->query("CREATE SEQUENCE ${seqname}"); $this->popErrorHandling(); return $result; } @@ -547,8 +547,8 @@ */ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP SEQUENCE ${seqname}"); } // }}}
Index: php4/pear/DB/common.php diff -u php4/pear/DB/common.php:1.78 php4/pear/DB/common.php:1.79 --- php4/pear/DB/common.php:1.78 Sat Jan 19 02:46:24 2002 +++ php4/pear/DB/common.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: common.php,v 1.78 2002/01/19 07:46:24 cox Exp $ +// $Id: common.php,v 1.79 2002/02/02 00:27:47 ssb Exp $ // // Base class for DB implementations. // @@ -95,7 +95,8 @@ var $options = array( 'persistent' => false, 'optimize' => 'performance', - 'debug' => 0 + 'debug' => 0, + 'seqname_format' => '%s_seq' ); /** @@ -1247,6 +1248,15 @@ } return $this->getCol($sql); // Launch this query } + // }}} + // {{{ getSequenceName() + + function getSequenceName($sqn) + { + return sprintf($this->getOption("seqname_format"), + preg_replace('/[^a-z0-9_]/i', '_', $sqn)); + } + // }}} } Index: php4/pear/DB/fbsql.php diff -u php4/pear/DB/fbsql.php:1.12 php4/pear/DB/fbsql.php:1.13 --- php4/pear/DB/fbsql.php:1.12 Tue Dec 11 10:31:15 2001 +++ php4/pear/DB/fbsql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: fbsql.php,v 1.12 2001/12/11 15:31:15 sebastian Exp $ +// $Id: fbsql.php,v 1.13 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's FrontBase // extension. @@ -424,7 +424,8 @@ $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); $repeat = 0; do { - $result = $this->query("INSERT INTO ${sqn}_seq VALUES(NULL)"); + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + $result = $this->query("INSERT INTO ${seqname} VALUES(NULL)"); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { $repeat = 1; @@ -448,7 +449,8 @@ function createSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq ". + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + return $this->query("CREATE TABLE ${seqname} ". '(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'. ' PRIMARY KEY(id))'); } @@ -459,7 +461,8 @@ function dropSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq RESTRICT"); + $seqname = sprintf($this->getOption("seqname_format"), $sqn); + return $this->query("DROP TABLE ${seqname} RESTRICT"); } // }}} Index: php4/pear/DB/mssql.php diff -u php4/pear/DB/mssql.php:1.38 php4/pear/DB/mssql.php:1.39 --- php4/pear/DB/mssql.php:1.38 Thu Dec 27 07:06:50 2001 +++ php4/pear/DB/mssql.php Fri Feb 1 19:27:47 2002 @@ -16,7 +16,7 @@ // | Authors: Sterling Hughes <sterling@php.net> | // +----------------------------------------------------------------------+ // -// $Id: mssql.php,v 1.38 2001/12/27 12:06:50 cox Exp $ +// $Id: mssql.php,v 1.39 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's Microsoft SQL Server // extension. @@ -292,11 +292,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("INSERT INTO ${sqn}_seq (vapor) VALUES (0)"); + $result = $this->query("INSERT INTO $seqname (vapor) VALUES (0)"); $this->popErrorHandling(); if ($ondemand && DB::isError($result) && ($result->getCode() == DB_ERROR || $result->getCode() == DB_ERROR_NOSUCHTABLE)) @@ -307,7 +307,7 @@ return $result; } } else { - $result = $this->query("SELECT @@IDENTITY FROM ${sqn}_seq"); + $result = $this->query("SELECT @@IDENTITY FROM $seqname"); $repeat = 0; } } while ($repeat); @@ -323,8 +323,8 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq". + $seqname = $this->getSequenceName($seq_name); + return $this->query("CREATE TABLE $seqname ". '([id] [int] IDENTITY (1, 1) NOT NULL ,' . '[vapor] [int] NULL)'); } @@ -333,8 +333,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP TABLE $seqname"); } // }}} Index: php4/pear/DB/mysql.php diff -u php4/pear/DB/mysql.php:1.85 php4/pear/DB/mysql.php:1.86 --- php4/pear/DB/mysql.php:1.85 Tue Jan 29 15:55:20 2002 +++ php4/pear/DB/mysql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: mysql.php,v 1.85 2002/01/29 20:55:20 chagenbu Exp $ +// $Id: mysql.php,v 1.86 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's MySQL // extension. @@ -479,13 +479,13 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { // XXX HACK: temporarily force error mode to "return" $tmp = $this->_default_error_mode; $this->_default_error_mode = PEAR_ERROR_RETURN; - $result = $this->query("UPDATE ${sqn}_seq ". + $result = $this->query("UPDATE ${seqname} ". 'SET id=LAST_INSERT_ID(id+1)'); $this->_default_error_mode = $tmp; if ($ondemand && DB::isError($result) && @@ -508,7 +508,7 @@ // Obtain a user-level lock... this will release any previous // application locks, but unlike LOCK TABLES, it does not abort // the current transaction and is much less frequently used. - $result = $this->getOne("SELECT GET_LOCK('${sqn}_seq_lock',10)"); + $result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); if (DB::isError($result)) { return $result; } @@ -518,13 +518,13 @@ return $this->mysqlRaiseError(1100); } - $highest_id = $this->getOne("SELECT MAX(id) FROM ${sqn}_seq"); + $highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}"); if (DB::isError($highest_id)) { return $highest_id; } // We should probably do something if $highest_id isn't // numeric, but I'm at a loss as how to handle that... - $result = $this->query("DELETE FROM ${sqn}_seq ". + $result = $this->query("DELETE FROM ${seqname} ". "WHERE id <> $highest_id"); if (DB::isError($result)) { return $result; @@ -533,7 +533,7 @@ // If another thread has been waiting for this lock, // it will go thru the above procedure, but will have no // real effect - $result = $this->getOne("SELECT RELEASE_LOCK('${sqn}_seq_lock')"); + $result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')"); if (DB::isError($result)) { return $result; } @@ -556,15 +556,15 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - $res = $this->query("CREATE TABLE ${sqn}_seq ". + $seqname = $this->getSequenceName($seq_name); + $res = $this->query("CREATE TABLE ${seqname} ". '(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'. ' PRIMARY KEY(id))'); if (DB::isError($res)) { return $res; } // insert yields value 1, nextId call will generate ID 2 - return $this->query("INSERT INTO ${sqn}_seq VALUES(0)"); + return $this->query("INSERT INTO ${seqname} VALUES(0)"); } // }}} @@ -572,8 +572,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP TABLE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP TABLE ${seqname}"); } // }}} Index: php4/pear/DB/oci8.php diff -u php4/pear/DB/oci8.php:1.44 php4/pear/DB/oci8.php:1.45 --- php4/pear/DB/oci8.php:1.44 Tue Jan 29 08:40:53 2002 +++ php4/pear/DB/oci8.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: oci8.php,v 1.44 2002/01/29 13:40:53 ssb Exp $ +// $Id: oci8.php,v 1.45 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's Oracle 8 // call-interface extension. @@ -576,11 +576,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->expectError(DB_ERROR_NOSUCHTABLE); - $result = $this->query("SELECT ${sqn}_seq.nextval FROM dual"); + $result = $this->query("SELECT ${seqname}.nextval FROM dual"); $this->popExpect(); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { @@ -605,8 +605,8 @@ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("CREATE SEQUENCE ${seqname}"); } // }}} @@ -614,8 +614,8 @@ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP SEQUENCE ${seqname}"); } // }}} Index: php4/pear/DB/odbc.php diff -u php4/pear/DB/odbc.php:1.51 php4/pear/DB/odbc.php:1.52 --- php4/pear/DB/odbc.php:1.51 Fri Jan 18 11:28:15 2002 +++ php4/pear/DB/odbc.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: odbc.php,v 1.51 2002/01/18 16:28:15 cox Exp $ +// $Id: odbc.php,v 1.52 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's ODBC // extension. @@ -357,10 +357,10 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { - $result = $this->query("update ${sqn}_seq set id = id + 1"); + $result = $this->query("update ${seqname} set id = id + 1"); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOT_FOUND) { $repeat = 1; @@ -368,7 +368,7 @@ if (DB::isError($result)) { return $result; } - $result = $this->query("insert into ${sqn}_seq (id) values(0)"); + $result = $this->query("insert into ${seqname} (id) values(0)"); } else { $repeat = 0; } @@ -378,7 +378,7 @@ return $result; } - $result = $this->query("select id from ${sqn}_seq"); + $result = $this->query("select id from ${seqname}"); if (DB::isError($result)) { return $result; } @@ -397,7 +397,7 @@ function createSequence($seq_name) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("CREATE TABLE ${sqn}_seq ". + return $this->query("CREATE TABLE ${seqname} ". '(id bigint NOT NULL,'. ' PRIMARY KEY(id))'); } Index: php4/pear/DB/pgsql.php diff -u php4/pear/DB/pgsql.php:1.63 php4/pear/DB/pgsql.php:1.64 --- php4/pear/DB/pgsql.php:1.63 Thu Jan 17 06:31:12 2002 +++ php4/pear/DB/pgsql.php Fri Feb 1 19:27:47 2002 @@ -17,7 +17,7 @@ // | Stig Bakken <ssb@fast.no> | // +----------------------------------------------------------------------+ // -// $Id: pgsql.php,v 1.63 2002/01/17 11:31:12 cox Exp $ +// $Id: pgsql.php,v 1.64 2002/02/02 00:27:47 ssb Exp $ // // Database independent query interface definition for PHP's PostgreSQL // extension. @@ -491,11 +491,11 @@ */ function nextId($seq_name, $ondemand = true) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $repeat = 0; do { $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("SELECT NEXTVAL('${sqn}_seq')"); + $result = $this->query("SELECT NEXTVAL('${seqname}')"); $this->popErrorHandling(); if ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { @@ -528,9 +528,9 @@ */ function createSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); + $seqname = $this->getSequenceName($seq_name); $this->pushErrorHandling(PEAR_ERROR_RETURN); - $result = $this->query("CREATE SEQUENCE ${sqn}_seq"); + $result = $this->query("CREATE SEQUENCE ${seqname}"); $this->popErrorHandling(); return $result; } @@ -547,8 +547,8 @@ */ function dropSequence($seq_name) { - $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); - return $this->query("DROP SEQUENCE ${sqn}_seq"); + $seqname = $this->getSequenceName($seq_name); + return $this->query("DROP SEQUENCE ${seqname}"); } // }}}