【php开源代码栏目提醒】:网学会员php开源代码为您提供dbo_adodb.php参考,解决您在dbo_adodb.php学习中工作中的难题,参考学习。
<?php
/* SVN FILE: $Id: dbo_adodb.php 4409 2007-02-02 13:20:59Z phpnut $ */
/**
* AdoDB layer for DBO.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) : Rapid Development Framework <http://www.cakephp.org/>
* Copyright 2005-2007, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
* @link http://www.cakefoundation.org/projects/info/cakephp Cake
PHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP(tm) v 0.2.9
* @version $Revision: 4409 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-02-02 07:20:59 -0600 (Fri, 02 Feb 2007) $
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Include AdoDB files.
*/
vendor ('adodb' . DS . 'adodb.inc');
uses ('model' . DS . 'datasources' . DS . 'dbo_source');
/**
* AdoDB DBO implementation.
*
* Database abstraction implementation for the AdoDB library.
*
* @package cake
* @subpackage cake.cake.libs.model.dbo
*/
class DboAdodb extends DboSource {
/**
* Enter description here...
*
* @var string
*/
var $description = "ADOdb DBO Driver";
/**
* ADOConnection object with which we connect.
*
* @var ADOConnection The connection object.
* @access private
*/
var $_adodb = null;
/**
* Array translating ADOdb column MetaTypes to cake-supported metatypes
*
* @var array
* @access private
*/
var $_adodb_column_types = array(
'C' => 'string',
'X' => 'text',
'D' => 'date',
'T' => 'timestamp',
'L' => 'boolean',
'N' => 'float',
'I' => 'integer',
'R' => 'integer', // denotes auto-increment or counter field
'B' => 'binary'
);
/**
* Connects to the database using options in the given configuration array.
*
* @param array $config Configuration array for connecting
*/
function connect() {
$config = $this->config;
$persistent = strrpos($config['connect'], '|p');
if ($persistent === false) {
$adodb_driver = $config['connect'];
$connect = 'Connect';
} else {
$adodb_driver = substr($config['connect'], 0, $persistent);
$connect = 'PConnect';
}
$this->_adodb = NewADOConnection($adodb_driver);
$adodb = &$this->_adodb;
$this->connected = $adodb->$connect($config['host'], $config['login'], $config['pass
word'], $config['database']);
return $this->connected;
}
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
function disconnect() {
return $this->_adodb->Close();
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @return resource Result resource identifier
*/
function _execute($sql) {
global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
return $this->_adodb->execute($sql);
}
/**
* Returns a row from given resultset as an array .
*
* @return array The fetched row as an array
*/
/**
* Returns a row from current resultset as an array .
*
* @return array The fetched row as an array
*/
function fetchRow($sql = null) {
if (!empty($
sql) && is_string($sql) && strlen($sql) > 5) {
if (!$this->execute($sql)) {
return null;
}
}
if (!is_object($this->_result) || $this->_result->EOF) {
return null;
} else {
$resultRow = $this->_result->FetchRow();
$this->resultSet($resultRow);
return $this->fetchResult();
}
}
/**
* Begin a transaction
*
* @param unknown_type $model
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions).
*/
function begin(&$model) {
if (parent::begin($model)) {
if ($this->_adodb->BeginTrans()) {
$this->__transactionStarted = true;
return true;
}
}
return false;
}
/**
* Commit a transaction
*
* @param unknown_type $model
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
*/
function commit(&$model) {
if (parent::commit($model)) {
$this->__transactionStarted = false;
return $this->_adodb->CommitTrans();
}
return false;
}
/**
* Rollback a transaction
*
* @param unknown_type $model
* @return boolean True on success, false on fail
* (i.e. if the database/model does not support transactions,
* or a transaction has not started).
*/
function rollback(&$model) {
if (