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

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时,找不到表或者字段。

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

 

 

 

 

 

 

 

 

                                   

posted @ 2022-07-04 12:16  穆晟铭  阅读(141)  评论(0编辑  收藏  举报