📜 ⬆️ ⬇️

Yii 1.1.9

The stable version of the PHP framework Yii with the number 1.1.9 has been released. In this release, about 60 improvements and bug fixes.

A complete list of changes can be viewed in the corresponding file . Before upgrading from earlier versions, it is important to read the instructions .

Russian-language documentation, as usual, is in a fully up-to-date state. In addition, corrected all typos found at the time of release. Thanks to everyone who uses Orphus on yiiframework.ru.
')
Consider the most interesting changes.



A more convenient way to define `through` in an ActiveRecord relationship



The though option was added in version 1.1.7, but the syntax was not very convenient, so it was decided to make it more explicit. The current version uses the following syntax:

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


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

- key1 is the key defined in the relation specified in through (in our case, this is posts ).
- key2 is the key defined in the model to which the relation points (in our case, this is Comment ).

through can be used for both HAS_ONE and HAS_MANY .

For details, this feature is described in the Relational Active Record section of the full guide.

Support for condition groups in Model :: relations ()



Now you can use condition groups when defining model relationships:

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


When using only one group of conditions, it can be specified as a string.

The ability to make a JOIN between models for given keys



In this version, it became possible to create relationships for a given pair PK-> FK without relying on the data scheme. This means that you can, for example, set the following relationship for the Day model:

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


In this case, Day may contain several Job s. However, they are not connected in the usual way. We set the key in the form of array('fk'=>'pk') , that is, at the output we get SQL like

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


Ability to override kernel classes with Yii :: $ classMap



Since 1.1.5, Yii has been able to pre-import classes and use them without explicitly importing or include . Now using the same approach, you can override the core classes .

Source: https://habr.com/ru/post/135595/


All Articles