PHP链接oracle的函数(1)
时间:2007-02-17 来源:PHP爱好者
PHP链接oracle的函数 tianhaiyise(转贴)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
关键字 PHP链接oracle的函数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
出处 news://news.newsfan.com
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logon() 开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_query() 通用select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_change() 数据库改变的通用函数(insert,delete,update)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_insert() insert,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_delete() delete,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_update() update,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_commit() 事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_rollback() 事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logoff() 断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
Class c_ora_db
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
变量定义
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_user = ""; 数据库用户名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_passwd = ""; 数据库口令
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_db = ""; 数据库名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_linkID = 0; 连线句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_stmtID = 0; 查询句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $color =""; 全局颜色
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_logon()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:连线句柄(整型)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_logon()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this->I_linkID = @OCILogon($this->C_user,$this->C_passwd,$this->C_db);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($this->I_linkID == 0){AlertExit('数据库链接失败,请与DBA联系!');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this->I_linkID;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:$C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define 需绑定的字段。数组型
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_start 开始取记录 -1则取出查询的所有记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_end 结束取纪录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:二维数组($A_rs)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:通过数字0,1,2....可访问对应字段的值; 或通过查询字段名也可访问对应字段的值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
如通过$A_rs[0][0]或$A_rs[0]['NAME']或$A_rs[0]['name']都可访问首条记录NAME字段
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_start,$I_end是配合分页使用的参数。
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$C_sql){AlertExit("参数不全!");}检查参数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
连接检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($this->I_linkID == 0){AlertExit('数据库链接失败,请与DBA联系!');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
格式检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$this -> I_stmtID){AlertExit(' sql格式出错!请与程序员联系');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
如果没指定绑定的字段,则从SQL语句中去取
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if($A_define=="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_Cur = explode("select",$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_Cur = explode("from",$A_Cur[1]);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define = explode(",",$A_Cur[0]);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
绑定数据库表字段
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(gettype($A_define) == "array") 查询列是数组
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define_up[$i] = trim(strtoupper($A_define[$i])); 大写并去除空格
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define_up);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIDefineByName($this -> I_stmtID,"$A_define_up[$i]",&$$A_define[$i]); 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif(trim($A_define) <> "") 查询列只有一个
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define_up = trim(strtoupper($A_define));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIDefineByName($this -> I_stmtID,"$A_define_up",&$$A_define);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
执行绑定好的SQL语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(!OCIExecute($this -> I_stmtID))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
echo "<font color=red><b>执行出错:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return false;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower = 0; 返回二维数组的第一维下标控制变量
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt = 0; 开始取数标识
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
while (OCIFetchInto($this -> I_stmtID,&$cur,OCI_ASSOC))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取查询出来的所有记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_start == -1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (gettype($A_define) == "array") 查询列是数组
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for ($i=0;$i<count($A_define);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up[$i]] <> $$A_define[$i])
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define[$i] = $cur[$A_define_up[$i]];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$i] = $$A_define[$i]; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define[$i]] = $$A_define[$i]; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up[$i]] = $$A_define[$i]; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif (trim($A_define) <> "") 查询列只有一个
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up] <> $$A_define)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define = $cur[$A_define_up];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][0] = $$A_define; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define] = $$A_define; 用小写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up] = $$A_define; 用大些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower++; 下标加一
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取出指定记录(配合分页使用)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_start <> -1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cnt >= $I_start)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt++;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_end - $I_start <> 0)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_end--;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (gettype($A_define) == "array")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define_up);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up[$i]] <> $$A_define[$i])
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define[$i] = $cur[$A_define_up[$i]];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$i] = $$A_define[$i]; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define[$i]] = $$A_define[$i]; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up[$i]] = $$A_define[$i]; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}elseif(trim($A_define) <> "")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up] <> $$A_define)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define = $cur[$A_define_up];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][0] = $$A_define; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define] = $$A_define; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up] = $$A_define; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower++;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}else
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
break; 如果$I_end-$I_start=0 表示取完记录并跳出while循环
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}else
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt++; 如果$cnt<$I_start,$cnt++
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
} while的结束
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
释放句柄并返回查询数据(一个二维数组)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIFreestatement($this -> I_stmtID);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $A_rs;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
} function的结束
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_change($C_sql,$A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:db change
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:$C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_bind 需绑定的字段。数组型
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:insert,delete,update通用
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_change($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$C_sql){AlertExit("参数不全!");}检查参数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
连接检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if($this -> I_linkID==""){ AlertExit("我们的数据库正忙,请稍后再连接!");}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
格式检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$this -> I_stmtID){AlertExit(' sql格式出错!请与程序员联系');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(gettype($A_bind) == "array")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_bind);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $$A_bind[$i];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind[$i] = StripSlashes($$A_bind[$i]); 去掉反斜线字元
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind[$i] = str_replace("<?","<?",$$A_bind[$i]); 过滤掉PHP标示
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_bind);$i++){
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIBindByName($this -> I_stmtID, ":$A_bind[$i]", &$$A_bind[$i], -1); 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif(trim($A_bind) <> "") 不是数组,是字符
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $$A_bind;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind = StripSlashes($$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind = str_replace("<?","<?",$$A_bind); 过滤掉PHP标示
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIBindByName($this -> I_stmtID, ":$arrBind", &$$A_bind, -1);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
执行并检测是否成功
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(!OCIExecute($this -> I_stmtID,OCI_DEFAULT))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
echo "<font color=red><b>执行出错:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return false;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
/*传回受影响的行数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $I_changenum;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_changenum = OCINumrows($this -> I_stmtID);*/
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
释放句柄,传回值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIFreeStatement($this -> I_stmtID);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return true;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_delete($C_sql)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:delete
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_delete($C_sql)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_insert($C_sql,A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:insert
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
A_bind 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_insert($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql,$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_update($C_sql,A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:update
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
A_bind 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_update($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql,$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_commit()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_commit()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCICommit($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_rollback()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_rollback()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCIRollback($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_logoff()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_logoff()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCILogoff($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logon() 开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_query() 通用select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_change() 数据库改变的通用函数(insert,delete,update)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_insert() insert,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_delete() delete,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_update() update,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_commit() 事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_rollback() 事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logoff() 断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
Class c_ora_db
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
变量定义
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_user = ""; 数据库用户名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_passwd = ""; 数据库口令
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_db = ""; 数据库名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_linkID = 0; 连线句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_stmtID = 0; 查询句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $color =""; 全局颜色
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
关键字 PHP链接oracle的函数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
出处 news://news.newsfan.com
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logon() 开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_query() 通用select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_change() 数据库改变的通用函数(insert,delete,update)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_insert() insert,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_delete() delete,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_update() update,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_commit() 事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_rollback() 事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logoff() 断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
Class c_ora_db
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
变量定义
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_user = ""; 数据库用户名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_passwd = ""; 数据库口令
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_db = ""; 数据库名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_linkID = 0; 连线句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_stmtID = 0; 查询句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $color =""; 全局颜色
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_logon()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:连线句柄(整型)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_logon()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this->I_linkID = @OCILogon($this->C_user,$this->C_passwd,$this->C_db);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($this->I_linkID == 0){AlertExit('数据库链接失败,请与DBA联系!');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this->I_linkID;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:$C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define 需绑定的字段。数组型
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_start 开始取记录 -1则取出查询的所有记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_end 结束取纪录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:二维数组($A_rs)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:通过数字0,1,2....可访问对应字段的值; 或通过查询字段名也可访问对应字段的值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
如通过$A_rs[0][0]或$A_rs[0]['NAME']或$A_rs[0]['name']都可访问首条记录NAME字段
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_start,$I_end是配合分页使用的参数。
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_query($C_sql,$A_define="",$I_start=-1,$I_end=-1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$C_sql){AlertExit("参数不全!");}检查参数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
连接检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($this->I_linkID == 0){AlertExit('数据库链接失败,请与DBA联系!');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
格式检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$this -> I_stmtID){AlertExit(' sql格式出错!请与程序员联系');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
如果没指定绑定的字段,则从SQL语句中去取
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if($A_define=="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_Cur = explode("select",$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_Cur = explode("from",$A_Cur[1]);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define = explode(",",$A_Cur[0]);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
绑定数据库表字段
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(gettype($A_define) == "array") 查询列是数组
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define_up[$i] = trim(strtoupper($A_define[$i])); 大写并去除空格
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define_up);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIDefineByName($this -> I_stmtID,"$A_define_up[$i]",&$$A_define[$i]); 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif(trim($A_define) <> "") 查询列只有一个
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_define_up = trim(strtoupper($A_define));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIDefineByName($this -> I_stmtID,"$A_define_up",&$$A_define);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
执行绑定好的SQL语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(!OCIExecute($this -> I_stmtID))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
echo "<font color=red><b>执行出错:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return false;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower = 0; 返回二维数组的第一维下标控制变量
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt = 0; 开始取数标识
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
while (OCIFetchInto($this -> I_stmtID,&$cur,OCI_ASSOC))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取查询出来的所有记录
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_start == -1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (gettype($A_define) == "array") 查询列是数组
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for ($i=0;$i<count($A_define);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up[$i]] <> $$A_define[$i])
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define[$i] = $cur[$A_define_up[$i]];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$i] = $$A_define[$i]; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define[$i]] = $$A_define[$i]; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up[$i]] = $$A_define[$i]; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif (trim($A_define) <> "") 查询列只有一个
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up] <> $$A_define)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define = $cur[$A_define_up];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][0] = $$A_define; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define] = $$A_define; 用小写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up] = $$A_define; 用大些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower++; 下标加一
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
取出指定记录(配合分页使用)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_start <> -1)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cnt >= $I_start)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt++;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($I_end - $I_start <> 0)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_end--;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (gettype($A_define) == "array")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_define_up);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up[$i]] <> $$A_define[$i])
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define[$i] = $cur[$A_define_up[$i]];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$i] = $$A_define[$i]; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define[$i]] = $$A_define[$i]; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up[$i]] = $$A_define[$i]; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}elseif(trim($A_define) <> "")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if ($cur[$A_define_up] <> $$A_define)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_define = $cur[$A_define_up];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][0] = $$A_define; 用数字访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define] = $$A_define; 用小些访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_rs[$lower][$A_define_up] = $$A_define; 用大写访问
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$lower++;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}else
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
break; 如果$I_end-$I_start=0 表示取完记录并跳出while循环
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}else
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$cnt++; 如果$cnt<$I_start,$cnt++
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
} while的结束
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
释放句柄并返回查询数据(一个二维数组)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIFreestatement($this -> I_stmtID);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $A_rs;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
} function的结束
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_change($C_sql,$A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:db change
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:$C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$A_bind 需绑定的字段。数组型
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:insert,delete,update通用
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_change($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$C_sql){AlertExit("参数不全!");}检查参数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
连接检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if($this -> I_linkID==""){ AlertExit("我们的数据库正忙,请稍后再连接!");}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
格式检测
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$this -> I_stmtID = OCIParse($this -> I_linkID,$C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if (!$this -> I_stmtID){AlertExit(' sql格式出错!请与程序员联系');}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(gettype($A_bind) == "array")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_bind);$i++)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $$A_bind[$i];
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind[$i] = StripSlashes($$A_bind[$i]); 去掉反斜线字元
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind[$i] = str_replace("<?","<?",$$A_bind[$i]); 过滤掉PHP标示
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
for($i=0;$i<count($A_bind);$i++){
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIBindByName($this -> I_stmtID, ":$A_bind[$i]", &$$A_bind[$i], -1); 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
elseif(trim($A_bind) <> "") 不是数组,是字符
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $$A_bind;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind = StripSlashes($$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$$A_bind = str_replace("<?","<?",$$A_bind); 过滤掉PHP标示
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIBindByName($this -> I_stmtID, ":$arrBind", &$$A_bind, -1);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
执行并检测是否成功
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
if(!OCIExecute($this -> I_stmtID,OCI_DEFAULT))
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
echo "<font color=red><b>执行出错:</b></font>SQL Error:<font color=red>$C_sql</font><br>";
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return false;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
/*传回受影响的行数
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
global $I_changenum;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
$I_changenum = OCINumrows($this -> I_stmtID);*/
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
释放句柄,传回值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
OCIFreeStatement($this -> I_stmtID);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return true;
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_delete($C_sql)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:delete
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_delete($C_sql)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_insert($C_sql,A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:insert
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
A_bind 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_insert($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql,$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_update($C_sql,A_bind)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:update
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:C_sql sql语句
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
A_bind 绑定
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:该函数只是为了使用直观,本质调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_update($C_sql,$A_bind="")
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return $this -> db_change($C_sql,$A_bind);
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_commit()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_commit()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCICommit($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_rollback()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_rollback()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCIRollback($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
函数名:db_logoff()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
作 用:断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
参 数:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
返回值:布尔值
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
备 注:无
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
function db_logoff()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
return (OCILogoff($this->I_linkID));
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
}
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logon() 开启数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_query() 通用select
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_change() 数据库改变的通用函数(insert,delete,update)
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_insert() insert,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_delete() delete,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_update() update,直接调用db_change()
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_commit() 事务递交
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_rollback() 事务回退
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
※db_logoff() 断开数据库连接
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
Class c_ora_db
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
{
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
变量定义
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_user = ""; 数据库用户名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_passwd = ""; 数据库口令
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $C_db = ""; 数据库名
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_linkID = 0; 连线句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $I_stmtID = 0; 查询句柄
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
var $color =""; 全局颜色
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
chi na it p owe r .comnZ7RYArtQ9P01f9Ab5lzZ9r2W
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
相关阅读 更多 +