【问题标题】:How to execute ORACLE stored procedure from yii application?如何从 yii 应用程序执行 ORACLE 存储过程?
【发布时间】:2014-06-27 06:16:09
【问题描述】:

我想创建一个存储过程,它获取字符串数组作为输入并返回行并使用 (Yii)php 将数据返回到 UI。我用谷歌搜索并得出结论,使用 refcursor 我们可以返回行类型的数据。在

中提到

[http://www.oracle.com/technetwork/articles/fuecks-sps-095636.html][1]

喜欢下面的

 create PROCEDURE latest(
    num_entries_in IN NUMBER,
    entries_cursor_out OUT cursorType
) AS

    BEGIN

        OPEN entries_cursor_out FOR
            SELECT * FROM blogs WHERE rownum < num_entries_in
            ORDER BY date_published DESC;

    END latest;

但问题是我想在 yii 框架中绑定游标数据,或者如何从 yii 执行该存储过程并执行该查询的响应?

【问题讨论】:

    标签: php oracle stored-procedures yii


    【解决方案1】:

    在你的protected/config/config.php配置数据库中。

    'db'=>array
    (
        'class'=>'CDbConnection',
        'connectionString'=>'oci:dbname=dbhost:dbport/orcl;charset=UTF8'
        'username'=>'###',
        'password'=>'###',
    ),
    

    要调用存储过程,请将此代码添加到您的模型/控制器中。

    $command = Yii::app()->db->createCommand('call latest(num_entries_in,entries_cursor_out )');
    $command->execute();
    print_r($command->queryRow());
    

    【讨论】:

      猜你喜欢
      • 2019-08-26
      • 1970-01-01
      • 2011-11-07
      • 2010-12-23
      • 2011-06-19
      • 1970-01-01
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多