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 關注
- 108 瀏覽
添加回答
舉報