Yii database query method, yii database method. Yii database query method, yii database method this article describes the yii database query method. For your reference, here are two query methods. Yii database query method, yii database method
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->condition="username 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.
Articles you may be interested in:
- Directory structure, entry file, and route settings in Yii Getting Started Tutorial
- Yii installation and hello world
- Yii PHP Framework practical Getting Started Tutorial (details)
- Yii Query Builder usage example tutorial
- How to beautify YII by using url components
- Yii removes the star number in the required field
- Batch delete of CGridView in Yii
- Yii permission control methods (three methods)
- YiiFramework knowledge point summary (graphic tutorial)
The following example describes how to query the yii database. For your reference, here are two query methods ....