1 回答

TA貢獻1848條經(jīng)驗 獲得超6個贊
您不應(yīng)將該類傳遞給 oci_parse 函數(shù)。它需要一個連接資源。您可以通過調(diào)用獲取資源oci_connect。在您的班級中,您的函數(shù)已經(jīng)在執(zhí)行此操作,因此您可以在函數(shù)中返回它。見下文。
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 關(guān)注
- 113 瀏覽
添加回答
舉報