【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了dbo_odbc.php提供大家参考,希望对大家有所帮助!
<?php
/* SVN FILE: $Id: dbo_odbc.php 4409 2007-02-02 13:20:59Z phpnut $ */
/**
* ODBC 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 CakePHP(tm) Project
* @package cake
* @subpackage cake.cake.libs.model.dbo
* @since CakePHP(tm) v 0.10.5.1790
* @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 DBO.
*/
uses ('model' . DS . 'datasources' . DS . 'dbo_source');
/**
* Short description for class.
*
* Long description for class
*
* @package cake
* @subpackage cake.cake.libs.model.dbo
*/
class DboOdbc extends DboSource{
/**
* Driver description
*
* @var string
*/
var $description = "ODBC DBO Driver";
/**
* Table/column starting quote
*
* @var string
*/
var $startQuote = "`";
/**
* Table/column end quote
*
* @var string
*/
var $endQuote = "`";
/**
* Driver base configuration
*
* @var array
*/
var $_baseConfig = array('persistent' => true,
'login' => 'root',
'password' => '',
'database' => 'cake',
'connect' => 'odbc_pconnect'
);
/**
* Enter description here...
*
* @var unknown_type
*/
var $columns = array();
// var $columns = array('primary_key' => array('name' => 'int(11) DEFAULT NULL auto_increment'),
// 'string' => array('name' => 'varchar', 'limit' => '255'),
// 'text' => array('name' => 'text'),
// 'integer' => array('name' => 'int', 'limit' => '11'),
// 'float' => array('name' => 'float'),
// 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
// 'timestamp' => array('name' => 'datetime', 'format' => 'Y-m-d h:i:s', 'formatter' => 'date'),
// 'time' => array('name' => 'time', 'format' => 'h:i:s', 'formatter' => 'date'),
// 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'),
// 'binary' => array('name' => 'blob'),
// 'boolean' => array('name' => 'tinyint', 'limit' => '1'));
/**
* Connects to the database using options in the given configuration array.
*
* @return boolean True if the database could be connected, else false
*/
function connect() {
$config = $this->config;
$connect = $config['connect'];
$this->connected = false;
$this->connection = $connect($config['database'], $config['login'], $config['password']);
if ($this->connection) {
$this->connected = true;
}
return $this->connected;
}
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
function disconnect() {
return@odbc_close($this->connection);
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @return resource Result resource identifier
* @access protected
*/
function _execute($sql) {
return odbc_exec($this->connection, $sql);
}
/**
* Returns a row from given resultset as an array .
*
* @param bool $assoc Associative array only, or both?
* @return array The fetched row as an array
*/
function fetchRow($assoc = false) {
if (is_resource($this->_result)) {
$this->resultSet($this->_result);
$resultRow = $this->fetchResult();
return $resultRow;
} else {
return null;
}
}
/**
* Returns an array of sources (tables) in the database.
*
* @return array Array of tablenames in the database
*/
function listSources() {
$cache = pa