Showing posts with label Yii2 select query. Show all posts
Showing posts with label Yii2 select query. Show all posts

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