One of the things you will find tricky to implement is the the sorting and filtering of a GridView’s column that displays related model data. As you know if you have been playing with Yii2 lately, there is a new proposed way to search for data and is by using objects that extend from the… Continue reading Yii 2.0: Displaying, Sorting and Filtering Model Relations on a GridView, Gridview with relationships
Month: November 2015
How to import an SQL file using the command line in MySQL?
How to import an SQL file using the command line in MySQL? mysql -u username -p database_name < /path/file.sql It will ask for password after this command
YII2 nav widget open link in new tab/window and how to link to external link
echo Nav::widget([ ‘options’ => [‘class’ => ‘nav navbar-left nav-tabs’], ‘items’ => [ [ ‘label’ => ‘Schedule An Appointment’, ‘url’ => ‘http://google.com’, ‘linkOptions’ => [‘target’ => ‘_blank’] ], ], ]);
Yii2 query / query builder: how to use OR condition
Yii2 query / query builder: how to use OR condition You can use some thing like this: $third_res_count=CustomerReservedTimeslots::find() ->select([‘COUNT(timeslot_id) AS cnt’]) ->where([ ‘test_date’ => $today_date, ‘confirmed’ => ‘1’, ]) ->andWhere([‘>’, ‘third_user_id’, ‘0’]) ->andFilterWhere([ ‘or’, [‘like’, ‘status’, ‘checked in’], [‘like’, ‘status’, ‘Waiting for check in’], ]) ->one();
YII2 DB Count Results query
YII2 DB count results query Simple in the controller or view file add do this: $count=MODEL::find() ->select([‘COUNT(id) AS cnt’]) ->where([ ‘field1’ => $value1, ])-> andWhere([‘>’, ‘field2’, $value2]) ->one()->cnt; And in the model of the table add before this line: public static function tableName() Add public $cnt; like below: public $cnt; public static… Continue reading YII2 DB Count Results query