: This article describes how to query the yii Database. For more information about PHP tutorials, see. This article describes how to query the yii database. We will share this with you for your reference. The details are as follows:
Two query methods are described here. One is direct query, and the other is to use criteria for query.
The code is as follows:
$ User = User: model ();
1. direct query:
$ Arr = array ("select" => "username, password, email", // the field to be queried "condition" => "username like '% 6 '", // query condition "order" => "id desc", "limit" => 5, "offset" => 1 ,); $ info = $ user-> findAll ($ arr );
2. use criteria:
$ Criteria = new CDbCriteria (); $ criteria-> select = "username, password, email"; $ criteria-> c like '% 1 '"; $ criteria-> limit = 5; $ criteria-> order = "id desc"; $ criteria-> offset = 1; $ info = $ user-> findAll ($ criteria );
I hope this article will help you design PHP programs based on the yii Framework.
The above introduces the yii database query method, including the content, hope to be helpful to friends interested in PHP tutorials.