Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv13825
Modified Files:
db_msql.inc db_mssql.inc db_odbc.inc db_pgsql.inc
db_sybase.inc
Log Message:
Added instance variable 'PConnect' to toggle between persistent and non-persistent database connections.
The default behavior is non-persistent.
Index: db_msql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_msql.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** db_msql.inc 12 Jul 2000 18:22:34 -0000 1.3
--- db_msql.inc 14 Mar 2002 20:41:07 -0000 1.4
***************
*** 24,27 ****
--- 24,28 ----
var $Auto_Free = 0; ## Set this to 1 for automatic msql_free_result()
+ var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
***************
*** 34,45 ****
if ( 0 == $this->Link_ID ) {
// Check for local connect
! $this->Link_ID = empty($this->Host)?
! $this->Link_ID=msql_pconnect():
! $this->Link_ID=msql_pconnect($this->Host);
}
// Still not connected? Raise error.
if ( 0 == $this->Link_ID ) {
! $this->halt("Link-ID == false, pconnect failed");
}
--- 35,52 ----
if ( 0 == $this->Link_ID ) {
// Check for local connect
! if(!$this->PConnect) {
! $this->Link_ID = empty($this->Host) ?
! $this->Link_ID = msql_connect() :
! $this->Link_ID = msql_connect($this->Host);
! } else {
! $this->Link_ID = empty($this->Host) ?
! $this->Link_ID = msql_pconnect() :
! $this->Link_ID = msql_pconnect($this->Host);
! }
}
// Still not connected? Raise error.
if ( 0 == $this->Link_ID ) {
! $this->halt("connect($this->Host) failed.");
}
Index: db_mssql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_mssql.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** db_mssql.inc 17 May 2001 01:19:37 -0000 1.3
--- db_mssql.inc 14 Mar 2002 20:41:07 -0000 1.4
***************
*** 26,29 ****
--- 26,30 ----
var $Auto_Free = 0; ## set this to 1 to automatically free results
+ var $PConnect = 0; ## Set to 1 to persistent database connections
***************
*** 35,41 ****
function connect() {
if ( 0 == $this->Link_ID ) {
! $this->Link_ID=mssql_pconnect($this->Host, $this->User, $this->Password);
if (!$this->Link_ID)
! $this->halt("Link-ID == false, mssql_pconnect failed");
else
mssql_select_db($this->Database, $this->Link_ID);
--- 36,46 ----
function connect() {
if ( 0 == $this->Link_ID ) {
! if(!$this->PConnect) {
! $this->Link_ID = mssql_connect($this->Host, $this->User, $this->Password);
! } else {
! $this->Link_ID = mssql_pconnect($this->Host, $this->User, $this->Password);
! }
if (!$this->Link_ID)
! $this->halt("connect($this->Host, $this->User, \$Password) failed.");
else
mssql_select_db($this->Database, $this->Link_ID);
Index: db_odbc.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_odbc.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** db_odbc.inc 12 Jul 2000 18:22:34 -0000 1.3
--- db_odbc.inc 14 Mar 2002 20:41:07 -0000 1.4
***************
*** 25,28 ****
--- 25,29 ----
var $Auto_Free = 0; ## set this to 1 to automatically free results
+ var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
***************
*** 33,39 ****
function connect() {
if ( 0 == $this->Link_ID ) {
! $this->Link_ID=odbc_pconnect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
if (!$this->Link_ID) {
! $this->halt("Link-ID == false, odbc_pconnect failed");
}
}
--- 34,44 ----
function connect() {
if ( 0 == $this->Link_ID ) {
! if(!$this->PConnect) {
! $this->Link_ID = odbc_connect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
! } else {
! $this->Link_ID = odbc_pconnect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
! }
if (!$this->Link_ID) {
! $this->halt("connect($this->Database, $this->User, \$Password, $this->UseODBCCursor) failed.");
}
}
Index: db_pgsql.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_pgsql.inc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** db_pgsql.inc 13 Dec 2000 17:46:50 -0000 1.6
--- db_pgsql.inc 14 Mar 2002 20:41:07 -0000 1.7
***************
*** 29,32 ****
--- 29,33 ----
var $Auto_Free = 0; # Set this to 1 for automatic pg_freeresult on
# last record.
+ var $PConnect = 0; ## Set to 1 to use persistent database connections
function ifadd($add, $me) {
***************
*** 40,54 ****
function connect() {
! if ( 0 == $this->Link_ID ) {
! $cstr = "dbname=".$this->Database.
! $this->ifadd($this->Host, "host=").
! $this->ifadd($this->Port, "port=").
! $this->ifadd($this->User, "user=").
! $this->ifadd($this->Password, "password=");
! $this->Link_ID=pg_pconnect($cstr);
! if (!$this->Link_ID) {
! $this->halt("Link-ID == false, pconnect failed");
! }
! }
}
--- 41,59 ----
function connect() {
! if ( 0 == $this->Link_ID ) {
! $cstr = "dbname=".$this->Database.
! $this->ifadd($this->Host, "host=").
! $this->ifadd($this->Port, "port=").
! $this->ifadd($this->User, "user=").
! $this->ifadd($this->Password, "password=");
! if(!$this->PConnect) {
! $this->Link_ID = pg_connect($cstr);
! } else {
! $this->Link_ID = pg_pconnect($cstr);
! }
! if (!$this->Link_ID) {
! $this->halt("connect() failed.");
! }
! }
}
Index: db_sybase.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/db_sybase.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** db_sybase.inc 12 Jul 2000 18:22:34 -0000 1.3
--- db_sybase.inc 14 Mar 2002 20:41:07 -0000 1.4
***************
*** 26,29 ****
--- 26,30 ----
var $Auto_Free = 0; ## Set this to 1 for automatic sybase_free_result()
+ var $PConnect = 0; ## Set to 1 to use persistent database connections
/* public: constructor */
***************
*** 34,42 ****
function connect() {
if ( 0 == $this->Link_ID ) {
! $this->Link_ID=sybase_pconnect($this->Host,$this->User,$this->Password);
if (!$this->Link_ID) {
! $this->halt("Link-ID == false, pconnect failed");
}
! if(!sybase_select_db($this->Database, $this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
--- 35,47 ----
function connect() {
if ( 0 == $this->Link_ID ) {
! if(!$this->PConnect) {
! $this->Link_ID = sybase_connect($this->Host, $this->User, $this->Password);
! } else {
! $this->Link_ID = sybase_pconnect($this->Host, $this->User, $this->Password);
! }
if (!$this->Link_ID) {
! $this->halt("connect($this->Host, $this->User, \$Password) failed.");
}
! if(!sybase_select_db($this->Database, $this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
|