【php开源代码栏目提醒】:网学会员--在 php开源代码编辑为广大网友搜集整理了:dbo_mssql.php绩等信息,祝愿广大网友取得需要的信息,参考学习。
<?php
/* SVN FILE: $Id: dbo_mssql.php 4450 2007-02-05 05:18:05Z phpnut $ */
/**
* MS SQL 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.10.5.1790
* @version $Revision: 4450 $
* @modifiedby $LastChangedBy: phpnut $
* @lastmodified $Date: 2007-02-04 23:18:05 -0600 (Sun, 04 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 DboMssql extends DboSource {
/**
* Enter description here...
*
* @var unknown_type
*/
var $description = "MS SQL DBO Driver";
/**
* Enter description here...
*
* @var unknown_type
*/
var $startQuote = "[";
/**
* Enter description here...
*
* @var unknown_type
*/
var $endQuote = "]";
/**
* Enter description here...
*
* @var unknown_type
*/
var $goofyLimit = true;
/**
* Creates a map between field aliases and numeric indexes. Workaround for the
* SQL Server driver's 30-character column name limitation.
*
* @var array
*/
var $__fieldMappings = array();
/**
* Base configuration settings for MS SQL driver
*
* @var array
*/
var $_baseConfig = array(
'persistent' => true,
'host' => 'localhost',
'login' => 'root',
'password' => '',
'database' => 'cake',
'port' => '1433',
'connect' => 'mssql_pconnect'
);
/**
* MS SQL column definition
*
* @var array
*/
var $columns = array(
'primary_key' => array('name' => 'int IDENTITY (1, 1) NOT NULL'),
'string' => array('name' => 'varchar', 'limit' => '255'),
'text' => array('name' => 'text'),
'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'),
'float' => array('name' => 'float', 'formatter' => 'floatval'),
'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'),
'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'),
'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'),
'binary' => array('name' => 'image'),
'boolean' => array('name' => 'bit')
);
/**
* MS SQL DBO driver constructor; sets SQL Server error reporting defaults
*
* @param array $config Configuration data from app/config/databases.php
* @return boolean True if connected successfully, false on error
*/
function __construct($config) {
mssql_min_message_severity(15);
mssql_min_error_severity(2);
return parent::__construct($config);
}
/**
* 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'];
$os = env('OS');
if (!empty($os) && strpos($os, 'Windows') !== false) {
$sep = ',';
} else {
$sep = ':';
}
$this->connected = false;
if (is_numeric($config['port'])) {
$port = $sep . $config['port']; // Port number
} elseif ($config['port'] === null) {
$port = ''; // No port - SQL Server 2005
} else {
$port = '\\' . $config['port']; // Named pipe
}
$this->connection = $connect($config['host'] . $port, $config['login'], $config['pass
word']);
if (ms
sql_select_db($config['database'], $this->connection)) {
$this->connected = true;
}
}
/**
* Disconnects from database.
*
* @return boolean True if the database could be disconnected, else false
*/
function disconnect() {
return @mssql_close($this->connection);
}
/**
* Executes given SQL statement.
*
* @param string $sql SQL statement
* @return resource Result resource identifier
* @access protected
*/
function _execute($sql) {
return mssql_query($sql, $this->connection);
}
/**
* Returns a row from given resultset as an array .
*
* @param bool $assoc Associative array only