php可以兼容odbc和OCI两种连接数据库方法
时间:2008-05-29 来源:剑心通明
PHP 作的最不好的一点就是为每一种数据库都设计了一种数据库连接方法,这样虽然可以兼容大多数的数据库,但是一旦数据库需要改变,则大事不妙!
在这里,我给大家介绍一种我自己的一点心得,希望能够起到抛砖引玉的效果!
我的程序代码如下:
以下为引用的内容:
phperz.com
//$stmt=odbc_exec($conn,$sql);
//OCI
$stmt=ociparse($conn,$sql);
ociexecute($stmt);
return $stmt;
}
function GetColumn($stmt,$colname){
//odbc
//$ret=odbc_result($stmt,$colname);
//OCI
$ret=ociresult($stmt,$colname);
return $ret;
}
function FecthRow($stmt){
//ODBC
//$ret=odbc_fetch_row($stmt);
//OCI
$ret=ocifetch($stmt);
return $ret;
}
?>
这样,一旦数据库连接发生变化,我们只需要修改这个函数模块即可!
在实际的应用中的代码如下:
以下为引用的内容:
www.phperz.com
欢迎大家批评指导!
在这里,我给大家介绍一种我自己的一点心得,希望能够起到抛砖引玉的效果!
我的程序代码如下:
以下为引用的内容:
phperz.com
//$stmt=odbc_exec($conn,$sql);
//OCI
$stmt=ociparse($conn,$sql);
ociexecute($stmt);
return $stmt;
}
function GetColumn($stmt,$colname){
//odbc
//$ret=odbc_result($stmt,$colname);
//OCI
$ret=ociresult($stmt,$colname);
return $ret;
}
function FecthRow($stmt){
//ODBC
//$ret=odbc_fetch_row($stmt);
//OCI
$ret=ocifetch($stmt);
return $ret;
}
?>
这样,一旦数据库连接发生变化,我们只需要修改这个函数模块即可!
在实际的应用中的代码如下:
以下为引用的内容:
www.phperz.com
欢迎大家批评指导!
相关阅读 更多 +