How to wrap data column in Gridview widget in yii or yii2 framework

The column which you want to wrap should be added the property called “contentOptions” where you can apply the css property to suits your needs and requirements as below.

[
‘attribute’ => ‘column name’,
‘format’ => ‘html’,
‘noWrap’ => false,
‘mergeHeader’=>true,
‘contentOptions’ => [‘style’ => ‘width: 50%; overflow: scroll;word-wrap: break-word;white-space:pre-line;’],
‘value’=>function ($data) {
return $data[‘question’];
},
],

How to get raw sql query in yii or yii2 framework

If you have used the query builder in yii 2.0.8 framework then to get the raw sql generated use the below statement.

$query->andFilterWhere([‘like’, ‘username’, $this->username])
->andFilterWhere([‘like’, ’email_id’, $this->email])
->andFilterWhere([‘registration_date’ => $this->register_date]);
// This is echo the raw query generated
var_dump($query->createCommand()->getRawSql());