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();

1 comment:

  1. Nice blog...Very useful information is providing by ur blog..here is a way to find.
    Hire Remote Yii Developers in India

    ReplyDelete

Recent Update

yii2 session handling

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

Most Search