我使用oracle适配器建立与db的连接,这是application.ini中的配置,
resources.db.adapter = "Oracle"
resources.db.params.host = "localhost"
resources.db.params.username = "user"
resources.db.params.password = "2012"
resources.db.params.dbname = "books"
resources.db.isDefaultTableAdapter = true
以及我如何调用存储过程
$db = Zend_Db_Table::getDefaultAdapter();
try {
// $sql = "select * from dual";
$sql = "begin BA_OPERATIONS_PKG.GETMEMBERCRED(" .
":I_USER_ID, :DATA_REC); end;";
$statement = new Zend_Db_Statement_Oracle($db, $sql);
$params = array(
'I_USER_ID' => $userId
);
// Create a cursor
$cursor = new Zend_Db_Cursor_Oracle($db);
// Bind the cursor as a parameter. This SHOULD push a new cursor in the
// $_bindCursor stack from Zend_Db_Statement.
$statement->bindCursor('DATA_REC', $cursor);
$statement->execute($params);
echo $cursor;
} catch (Exception $e) {
print_r($e->getMessage());
}
这是我的例外
include_once(Zend\Db\Cursor\Oracle.php) [function.include-once]: failed to open stream: No such file or directory in D:\ZendFramework\library\Zend\Loader.php
答案 0 :(得分:0)
我扩展了oracle适配器并添加了一个方法:
<?php
/**
* @see Zend_Db_Adapter_Pdo_Oci
*/
require_once 'Zend/Db/Adapter/Oracle.php';
class Zend_Db_Adapter_Cds extends Zend_Db_Adapter_Oracle
{
public function fetchCursor($sql, $bind = array())
{
$data = array();
$conn = $this->getConnection();
$curs = oci_new_cursor($conn);
$stmt = oci_parse($conn, $sql);
oci_bind_by_name($stmt, "cursor", $curs, -1, OCI_B_CURSOR);
foreach ($bind as $key => &$val) {
oci_bind_by_name($stmt, $key, $val, -1, OCI_ASSOC);
}
oci_execute($stmt);
if ($e = oci_error($stmt)) {
throw new Zend_Db_Adapter_Oracle_Exception($e, -1234);
}
oci_execute($curs);
if (oci_fetch_all($curs, $data, 0, -1, OCI_FETCHSTATEMENT_BY_ROW)) {
;//var_dump($data);
}
oci_free_statement($stmt);
oci_free_statement($curs);
return $data;
}
}