diff options
| author | Christian Fowler <spider@viovio.com> | 2006-01-31 17:08:05 +0000 |
|---|---|---|
| committer | Christian Fowler <spider@viovio.com> | 2006-01-31 17:08:05 +0000 |
| commit | 4b6d9813e138378a4697276699d650f377e17492 (patch) | |
| tree | 7e1cdcb24f5e6717cf02a450d5225e04d002e613 /BitDbPear.php | |
| parent | 99614cde0489da6847aa8b4fb28fa9be5e66fd52 (diff) | |
| download | kernel-4b6d9813e138378a4697276699d650f377e17492.tar.gz kernel-4b6d9813e138378a4697276699d650f377e17492.tar.bz2 kernel-4b6d9813e138378a4697276699d650f377e17492.zip | |
improve interoperability for Pear and ADODB to exist simultaneously as different objects to different placespre_table_detikification
Diffstat (limited to 'BitDbPear.php')
| -rwxr-xr-x | BitDbPear.php | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/BitDbPear.php b/BitDbPear.php index 6b74325..5c2051f 100755 --- a/BitDbPear.php +++ b/BitDbPear.php @@ -3,7 +3,7 @@ * ADOdb Library interface Class * * @package kernel - * @version $Header: /cvsroot/bitweaver/_bit_kernel/BitDbPear.php,v 1.2 2006/01/26 17:28:35 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_kernel/BitDbPear.php,v 1.3 2006/01/31 17:08:05 spiderr Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -21,8 +21,6 @@ require_once 'DB.php'; require_once( KERNEL_PKG_PATH.'BitDbBase.php' ); -define( 'BIT_QUERY_DEFAULT', -1 ); - /** * This class is used for database access and provides a number of functions to help * with database portability. @@ -35,33 +33,35 @@ define( 'BIT_QUERY_DEFAULT', -1 ); class BitDbPear extends BitDb { - function BitDbPear() + function BitDbPear( $pPearDsn=NULL ) { - global $gBitPearDbOptions, $gBitDbType, $gBitDbUser, $gBitDbPassword, $gBitDbHost, $gBitDbName; + global $gBitPearDbOptions; parent::BitDb(); - $pearDsn = array( - 'phptype' => $gBitDbType, - 'username' => $gBitDbUser, - 'password' => $gBitDbPassword , - 'hostspec' => $gBitDbHost, - 'database' => $gBitDbName, - ); - + if( empty( $pPearDsn ) ) { + global $gBitDbType, $gBitDbUser, $gBitDbPassword, $gBitDbHost, $gBitDbName; + $pPearDsn = array( + 'phptype' => $gBitDbType, + 'username' => $gBitDbUser, + 'password' => $gBitDbPassword , + 'hostspec' => $gBitDbHost, + 'database' => $gBitDbName, + ); + } - $this->mDb =& DB::connect($pearDsn, $gBitPearDbOptions); + $this->mDb =& DB::connect($pPearDsn, $gBitPearDbOptions); if( PEAR::isError( $this->mDb ) ) { die( $this->mDb->getMessage() ); } - PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'bit_error_handler'); + PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, 'bit_pear_error_handler'); $this->mDb->setFetchMode( DB_FETCHMODE_ASSOC ); // Default to autocommit unless StartTrans is called $this->mDb->autoCommit( TRUE ); - $this->mType = $pearDsn['phptype']; - $this->mName = $pearDsn['database']; + $this->mType = $pPearDsn['phptype']; + $this->mName = $pPearDsn['database']; } /** * Quotes a string to be sent to the database which is @@ -258,11 +258,10 @@ class BitDbPear extends BitDb function getOne($pQuery, $pValues=NULL, $pNumRows=NULL, $pOffset=NULL, $pCacheTime = BIT_QUERY_DEFAULT ) { $value = NULL; - $result = $this->query($pQuery, $pValues, 1, $pOffset, $pCacheTime ); - $res = ($result != NULL) ? $result->fetchRow() : false; - if( $res ) { - //$this->debugger_log($pQuery, $pValues); - $value = current($res); + if( $result = $this->query($pQuery, $pValues, 1, 0, $pCacheTime ) ) { + if( $res = $result->fetchRow() ) { + $value = current($res); + } } return $value; } @@ -413,7 +412,7 @@ bt(); } // This function will handle all errors -function bit_error_handler( $error_obj ) { +function bit_pear_error_handler( $error_obj ) { // Be verbose while developing the application if( !defined( 'IS_LIVE' ) ) { $dbParams = array( |
