Showing posts with label Select query in yii2. Show all posts
Showing posts with label Select query in yii2. Show all posts

Tuesday, April 10, 2018

Yii2 limit

Create a new instance of yii db Query.

Offset() define which is starting point and limit() define the number of rows.

Limit Query in Yii2

$query = (new Query())->select(['id'])->from('user');
$query->limit(10)->offset(10);

Monday, March 26, 2018

Where query in Yii2

In this example we are just fetching two columns data and also set limit 5. You can set your own limits and also set your own columns.

How to build where query in Yii2

$data = (new \yii\db\Query())
    ->select(['columnName1', 'columnName2'])
    ->from('table_name')
    ->where(['columnName' => 'value'])
    ->limit(5) //set limit
    ->all();

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search