本文介紹了使用 Active Record 在 Yii 中調用數據庫視圖的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我了解如何使用 Yii 的活動記錄環境查詢表.我找不到調用 mysql 視圖的文檔.另外,我知道如何使用 gii 工具為活動記錄中的表建模,但有沒有辦法為數據庫視圖執行此操作?
I understand how to query a table with Yii's active record environment. I can't find documentation for calling a mysql view. Also, I know how to model a table in active record with the gii tool, but is there a way to do this for a database view?
推薦答案
它應該可以像處理表格一樣正常工作.生成模型時使用視圖名稱即可.
It should work fine in the same way as with tables. Just use the view name when you generate the model.
請閱讀 Joshua 的回答并了解如何將主鍵添加到視圖的 OOP 模型中.
Please read Joshua's answer and learn how to add primary Key into the OOP model for views.
這篇關于使用 Active Record 在 Yii 中調用數據庫視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!