Yii2 dev digest #2 Dec'13Dec 4, 2013, 11:43:48 PM
It has gone some time after Yii2 Alpha announce, it increased activity in GitHub issues, a lot more people have tried to touch Yii2. And this is what I have noted.
- Extracted ActiveRecord Interface and BaseAR #886 #1359
- Extracted Active Relation feature
- Refatored StringHelper and FileHelper methods
- Eager loading, Active Record relation and asArray()
$drivers = Driver::find()->with('cars')->asArray()->all();
will get populated nested arrays with releations
- Configurable wrappers for checkbox and radio in BaseHtml
- DB Schema OCI [WIP]
- Elasticsearch debug toolbar; Screenshot
- Also added EmailTarget to log emails
- Support for Redis Sentinel planned for 2.0 RC
- Twitter Bootstrap Html helper moved to separate non-official extension
- There will no be PageState in Yii2
- Added SqlDataProvider
$count = Yii::$app->db->createCommand(' SELECT COUNT(*) FROM tbl_user WHERE status=:status ', [':status' => 1])->queryScalar(); $dataProvider = new SqlDataProvider([ 'sql' => 'SELECT * FROM tbl_user WHERE status=:status', 'params' => [':status' => 1], 'totalCount' => $count, 'sort' => [ 'attributes' => [ 'age', 'name' => [ 'asc' => ['first_name' => SORT_ASC, 'last_name' => SORT_ASC], 'desc' => ['first_name' => SORT_DESC, 'last_name' => SORT_DESC], 'default' => SORT_DESC, 'label' => 'Name', ], ], ], 'pagination' => [ 'pageSize' => 20, ], ]);
MyActiveRecord::find()->where(['id' => $primaryKey])->asArray()->one();
Support for HTML 5 Input Types
qiangxue > We will not add these input types to Html. You can easily use
Html::input($type, $name, $value)to achieve these.
Reuse of Query object
qiangxue > No, you cannot reuse the same query object for different queries. You need to create a new instance for each query.
Parsing an URL as a simple string
klimov-paul > It is better to create new Request instance and fill it up via “setter” methods. In simplest case “setUrl” should be enough:
use yii\web\Request; $request = new Request(); $request->setUrl('/site/contact'); Yii::$app->urlManager->parseRequest($request);
Yii::$app->mail->compose('contact/html') ->setFrom('firstname.lastname@example.org') ->setTo($form->email) ->setSubject($form->subject) ->send();
- Dashes in table field names, If you have a table where the field name contains dashes, Gii will generate variables with dashes.