Yii Framework 1.1.9 发布啦

chinaphp
 chinaphp
发布于 2012年01月01日
收藏 3

2012年第一天,Yii PHP framework 1.1.9已经发布了

We are very pleased to announce the immediate availability of Yii Framework version 1.1.9. In this release, we've included nearly 60 enhancements and bug fixes.

For the complete list of changes in this release, please see the change log and important feature additions. And if you plan to upgrade from an older version to 1.1.9, refer to the upgrade instructions.

In the following page, we briefly introduce some of the changes in this release.

More convenient way to define through AR relation

Active Record though option was introduced in 1.1.7 but syntax wasn't convenient so we decided to make it more definitive. Current syntax is the following:

'comments'=>array(self::HAS_MANY,'Comment',array('key1'=>'key2'),'through'=>'posts'),

In the above array('key1'=>'key2'):

  • key1 is a key defined in relation specified in through (posts is this case).
  • key2 is a key defined in a model relation points to (Comment in this case).

through can be used with both HAS_ONE and HAS_MANY relations.

For more details and examples refer to Relational Query with through.

Scope support for Model::relations()

You can now use scopes when defining AR model relations such as

'recentApprovedComments'=>array(self::BELONGS_TO, 'Post', 'post_id', 
    'scopes' => array('approved', 'recent')),

In case of a single scope you can specify a single scope with a string instead of array.

Ability to join AR models on a specific keys

It is now possible to build AR relations on PK->FK specified instead of relying on the schema defaults so you can specify AR relation like the following declaration for Day model:

'jobs'=>array(self::HAS_MANY, 'Job', array('date' => 'target_date')),

In the case above Day can have multiple Jobs but these aren't related usual way. We've specified relation key in form of array('fk'=>'pk'). That means it will generate SQL like

SELECT * FROM day t
JOIN job ON t.date = job.target_date

Ability to override core classes using Yii::$classMap

There was an ability to pre-import classes and use them without explicitly importing or including since 1.1.5. Now using the same technique you can override Yii core classes with your own ones.

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动共创开源社区。
转载请注明:文章转载自 开源中国社区 [http://www.oschina.net]
本文标题:Yii Framework 1.1.9 发布啦
加载中

最新评论(2

chinaphp
chinaphp
我们非常荣幸地宣布立即可用的1.1.9 Yii框架版本。本次发布的版本中,我们包括超过60处新特点、改进和修复错误。

如果查看本此版本的所有更新,请参阅更新日志和新功能。如果你准备升级,从一个更老的版本,请参阅,1.1.9升级的提示。
在下面,我们简略地介绍一下这个版本最新改进。谢谢你的支持!
一刀
一刀
连翻译都省了。。冏
返回顶部
顶部