我从以下oralce select查询中获取记录集时遇到问题:
SELECT ap.PROFILE_FIRST_NAME AS "profileFirstName",
CURSOR (
SELECT ae.EMAIL_ADDRESS AS "emailAddress",
ae.EMAIL_ADDRESS_IS_PRIMARY AS "emailAddressIsPrimary"
FROM APP_EMAIL_ADDRESS ae
WHERE ae.LOGIN_INFO_ID = ap.LOGIN_INFO_ID
) as "emails",
CURSOR(
select co.CONTACT_NUMBER AS "contactNumber"
FROM APP_CONTACT co where co.LOGIN_INFO_ID = ap.LOGIN_INFO_ID
) as "contacts"
FROM APP_PROFILE ap
当我在Toad中执行此查询时,它会按预期返回记录。 每个用户都有多个电子邮件和联系号码。但是当我在Zend中执行此查询时
$DB = Zend_Registry::get("DB");
$result = $DB->fetchAll($query);
$ result具有以下值:
Array
(
[0] => stdClass Object
(
[profileFirstName] =>
[emails] => Resource id #139
[contacts] => Resource id #140
)
[1] => stdClass Object
(
[profileFirstName] => Zain
[emails] => Resource id #141
[contacts] => Resource id #142
)
)
正如我所料,电子邮件应该是2D数组,以包含每个用户的电子邮件,因为联系人应该包含contacts数组。但问题是资源ID#。如何从Resource Id#获取这些值。
最好的问候
答案 0 :(得分:0)
这是我找到的解决这个问题的方法。
$DB = Zend_Registry::get("DB");
$con = $DB->getConnection();
$stmt = oci_parse($con, $query); // $query can be Resource #id
oci_execute($stmt);
while ($row = oci_fetch_object($stmt))