gpt4 book ai didi

javascript - 使用带有构造函数的 PHP 函数调用 Oracle 查询

转载 作者:行者123 更新时间:2023-12-03 08:30:53 24 4
gpt4 key购买 nike

我不知道我的错误在哪里,但我想在函数中存储 oracle 查询并在数组中返回该函数。

JobDrop.php

class JobDrop {
private $jobSql = "SELECT VMI.PROJECT_NO JOB FROM VW_MTO_INFO VMI ORDER BY VMI.PROJECT_NO ASC";

function _construct($jobSql){
$this->jobSql = $jobSql;
}

function JobDropdown($conn){
$jobParse = oci_parse($conn, $this->jobSql);
$jobExcErr = oci_execute($jobParse);

if (!$jobExcErr){
$e = oci_error($jobParse);
print htmlentities($e['message']);
print "\n<pre>\n";
print htmlentities($e['sqltext']);
printf("\n%".($e['offset']+1)."s", "^");
print "\n</pre>\n";
} else {

$res = array();
while ($row = oci_fetch_assoc($jobParse)){
$res[] = $row;
}
$listVendor = json_encode($res, JSON_PRETTY_PRINT);

return $listVendor;
}


}
}

在 test.php 中

include './job_drop.php';
require_once('../../lib/dbinfo.inc.php');
$conn = oci_connect(ORA_CON_UN, ORA_CON_PW, ORA_CON_DB);


$jobdrop = new JobDrop();

$jobdrop->JobDropdown($conn);
var_dump($jobdrop);

但它不显示浏览器内的数组。它显示查询字符串,

object(JobDrop)#1 (1) { ["jobSql":"JobDrop":private]=> string(74) "SELECT VMI.PROJECT_NO JOB FROM VW_MTO_INFO VMI ORDER BY VMI.PROJECT_NO ASC" } 

请帮我解决我做错的地方

最佳答案

如果你想查看数组,请执行以下操作:

$res = $jobdrop->JobDropdown($conn);
var_dump($res);

关于javascript - 使用带有构造函数的 PHP 函数调用 Oracle 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33338588/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com