1 回答
TA贡献1848条经验 获得超6个赞
您不应将该类传递给 oci_parse 函数。它需要一个连接资源。您可以通过调用获取资源oci_connect。在您的班级中,您的函数已经在执行此操作,因此您可以在函数中返回它。见下文。
class upSellCore
{
public function ociConnect($odb_user,$odb_pass,$odb_host,$odb_name)
{
$db = "(DESCRIPTION=(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ".$odb_host.")(PORT = 1521 )))(CONNECT_DATA=(SID=".$odb_name.")))";
$conn = oci_connect($odb_user, $odb_pass, $db);
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} else {
print "ERR01";
}
return $conn; // you need to return the connection.
}
}
$sql = "Select * from users ";
$upSell = new upSellCore();
$conn = $upSell->ociConnect($odb_user,$odb_pass,$odb_host,$odb_name); // you get the returned connection here and use it in the following line.
$stid = oci_parse($conn, $sql); // this is expecting a resource
- 1 回答
- 0 关注
- 78 浏览
添加回答
举报