PHP教程

YII2+oracle,php5.x升级到php7.2.x以上,sql报错:General error: 904 OCIStmtExecute: ORA-00904: "xxxx"

本文主要是介绍YII2+oracle,php5.x升级到php7.2.x以上,sql报错:General error: 904 OCIStmtExecute: ORA-00904: "xxxx",对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

YII2,php5.x升级到php7.2.x以上,sql报错:General error: 904 OCIStmtExecute: ORA-00904: "xxxx": invalid identifier

实际操作有发现2个问题:

             

1,model类型查询到报错:General error: 904 OCIStmtExecute: ORA-00904: "xxxx": invalid identifier
2. 原生sql没有报错

  

sql如下:

  public function actionIndex()
    {

        //model-sql
        $time = time() - 1500;
        $start = $time - 3600;
        $time_condition = array("between","CREATE_TIME",$start, $time);
        $datalist = Orders::find()->select(["ID","ORDER_ID"])
           // ->andFilterWhere($time_condition)
            ->andWhere(["CHANNEL"=>0])
           // ->andWhere(["NOT", ["PARENT_ID"=>null]])
            ->orderBy(["ID"=>SORT_DESC])->all();

        //原生sql
        $sql = "SELECT ID,ORDER_ID FROM wx_order where rownum <10";
        $datalist = Yii::$app->db->createCommand($sql)->queryAll();

        var_dump($datalist);exit;
    }

  

我这数据库是oracle,经过排查发现,用model写sql时,找不到表或者字段。

解决办法:将表名、字段名改成大小。

 

 

 

 

 

 

 

 

                                   

这篇关于YII2+oracle,php5.x升级到php7.2.x以上,sql报错:General error: 904 OCIStmtExecute: ORA-00904: "xxxx"的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!