【发布时间】:2014-05-04 00:10:04
【问题描述】:
我正在使用 PHP 和 oracle 数据库制作网站。 我有一个 connect.php 文件
<?php
$connect_error = "We are Experiencing Some Technical Difficulty";
oci_connect("asim","asim","localhost/xe") or die($connect_error);
?>
我在每一页都包含了这个文件!
但每当我必须执行查询时,我必须这样做
function user_exists($username){
$conn = oci_connect("asim","asim","localhost/xe");
$username = sanitize($username);
$stmt = oci_parse($conn,"SELECT COUNT(username)....");
oci_execute($stmt);
return ($stmt > 0) ? true:false;
}
我必须在每个函数中包含 $conn = oci_connect("asim","asim","localhost/xe"); 行。
有没有办法避免这种情况。
oci_execute Executes a statement previously returned from oci_parse(). oci_parse 需要 2 个参数,其中一个是 connection
【问题讨论】:
标签: php oracle database-connection connection-string oracle-call-interface