【php开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了php开源代码-DbIbase.class.php的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
<?php
// +----------------------------------------------------------------------
// | Think
PHP // +----------------------------------------------------------------------
// | Copyright (c) 2008 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
// $Id$
/**
+------------------------------------------------------------------------------
* Firebird鏁版嵁搴撻┍鍔ㄧ被 鍓戦浄 2007.12.28
+------------------------------------------------------------------------------
* @category Think
* @package Think
* @subpackage Db
* @author liu21st <liu21st@gmail.com>
* @version $Id$
+------------------------------------------------------------------------------
*/
Class DbIbase extends Db{
/**
+----------------------------------------------------------
* 鏋舵瀯鍑芥暟 璇诲彇鏁版嵁搴撻厤缃俊鎭?
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @param array $config 鏁版嵁搴撻厤缃暟缁?
+----------------------------------------------------------
*/
public function __construct($config=''){
if ( !extension_loaded('interbase') ) {
throw_exception(L('_NOT_SUPPERT_').':Interbase or Firebird');
}
if(!empty($config)) {
$this->config = $config;
}
//璇诲彇鏁版嵁缁撴灉闆嗙被鍨?
$this->resultType=C('DATA_RESULT_TYPE');
}
/**
+----------------------------------------------------------
* 杩炴帴鏁版嵁搴撴柟娉?
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
public function connect($config='',$linkNum=0) {
if ( !isset($this->linkID[$linkNum]) ) {
if(empty($config)) $config = $this->config;
$conn = $this->pconnect ? 'ibase_pconnect':'ibase_connect';
$this->linkID[$linkNum] = $conn( $config['hostname'].'/'.$config['hostport'].':'.$config['database'], $config['username'], $config['password']);
if ( !$this->linkID[$linkNum]) {
throw_exception(ibase_errmsg());
return False;
}
//鍓戦浄 2007.12.28
if ( ($svc = ibase_service_attach($config['hostname'], $config['username'], $config['pass
word'])) != FALSE)
{
$ibase_info = ibase_server_info ($svc, IBASE_SVC_SERVER_VERSION) . '/' . ibase_server_info($svc, IBASE_SVC_IMPLEMENTATION);
ibase_service_detach ($svc);
}
else
{
$ibase_info = 'Unable to Determine';
}
$this->dbVersion = $ibase_info;
// 鏍囪杩炴帴鎴愬姛
$this->connected = true;
// 娉ㄩ攢鏁版嵁搴撹繛鎺ラ厤缃俊鎭?
if(1 != C('DB_DEPLOY_TYPE')) unset($this->config);
}
return $this->linkID[$linkNum];
}
/**
+----------------------------------------------------------
* 閲婃斁鏌ヨ缁撴灉
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
public function free() {
@ibase_free_result($this->queryID);
$this->queryID = 0;
}
/**
+----------------------------------------------------------
* 鎵ц鏌ヨ 涓昏閽堝 SELECT, SHOW 绛夋寚浠?
* 杩斿洖鏁版嵁闆?
+----------------------------------------------------------
* @access protected
+----------------------------------------------------------
* @param string $str sql鎸囦护
+----------------------------------------------------------
* @return resultSet
+----------------------------------------------------------
* @throws ThinkExecption
+----------------------------------------------------------
*/
protected function _query($str='') {
$this->initConnect(false);
if ( !$this->_linkID ) return false;
if ( $str != '' ) $this->queryStr = $str;
if (!$this->autoCommit && $this->isMainIps($this->queryStr)) {
$this->startTrans();
}else {
//閲婃斁鍓嶆