尝试使用 zend 框架连接到数据库时出错


Error while trying to connect to DB using zend framework

我正在使用oracle适配器连接到db,这是应用程序中的配置.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 

我扩展了 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;
    }
}