Yii Framework Forum: Status update: ActiveRecord - Yii Framework Forum

Jump to content

  • (7 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

Status update: ActiveRecord

#121 User is offline   Haensel 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 444
  • Joined: 14-January 11
  • Location:Vienna (Austria)

Posted 06 May 2013 - 01:51 AM

What I really like: It seems to be a lot easier now to create a data provider from a relation. This wasn't possible in Yii 1.x as you had no access to the underlying db criteria object (it just returned a simple array). That was a huge pain for me in 1.x
0

#122 User is offline   xicond 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 06-October 12

Posted 06 May 2013 - 04:17 AM

View Postqiang, on 27 March 2012 - 11:03 AM, said:

I forgot to describe another important new feature: AR now can detect if an attribute is dirty or not, and by default it will only save dirty attributes to DB.

Regarding the removal of STAT, as Psih said, it doesn't belong to AR. However, considering the fact it does bring some convenience, we may support it in some different form (such as via a helper class).

@ololo: Because we now only differentiate has_one and has_many, it is necessary to specify the 'link' option. Since we have Gii, we expect much of these code will be generated automatically.


I like that new feature, and improvement for STAT more adaptive conversion from query to AR
0

#123 User is offline   saman 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 23-August 12

Posted 08 May 2013 - 05:25 PM

Hi is new active record support relation save like the behavior with-relation already build for 1.1?, i looked the code of activerecord but did not see anything for this purpose, mr qiang said before it implemented, but could not find the guid for this subject
0

#124 User is offline   Müller 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 23-June 12
  • Location:Netherlands

Posted 09 May 2013 - 05:22 AM

View Postsaman, on 08 May 2013 - 05:25 PM, said:

Hi is new active record support relation save like the behavior with-relation already build for 1.1?, i looked the code of activerecord but did not see anything for this purpose, mr qiang said before it implemented, but could not find the guid for this subject


Look at the methods "link" and "unlink" on "ActiveRecord" class

https://github.com/y...ecord.php#L1150

https://github.com/y...ecord.php#L1225
0

#125 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 May 2013 - 04:16 AM

View Postsamdark, on 05 May 2013 - 08:09 AM, said:

Relations now are to be implemented differently: https://github.com/y...ActiveRecord.md


I think i've read it somewhere but i'm not sure anymore. The code seems to confirm it though: There's no JOIN query at all anymore for any relational query, is that right? Related records are always fetched through separate queries?
0

#126 User is offline   Keith 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,670
  • Joined: 04-March 10
  • Location:UK

Posted 17 May 2013 - 04:22 AM

It would seem so. Is there no risk of performance issues in running the relational query with a large number of base table ID's? Also, how are composite keys handled?
0

#127 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,778
  • Joined: 17-January 09
  • Location:Russia

Posted 17 May 2013 - 05:21 AM

Mike
Yes. Usually first query is getting a list of IDs, second one is getting records themselves. That's actually a bit faster and caching-friendly.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#128 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 May 2013 - 07:30 AM

Ok, thanks. Even though i don't agree that 2 queries are faster per se, i see the point in this design decision. Querying related records in Yii1 could become a real pain in complex scenarios. The implementation is probably much more lightweight and understandable. Will have a closer look ;)
0

#129 User is offline   igorsantos07 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 29-May 10
  • Location:Rio de Janeiro, Brazil

Posted 21 June 2013 - 04:26 PM

Sorry, I'm a current Yii 1.1 developer and was trying to follow the discussions in this post, but I kinda got lost.

One of the things I noticed strange in the new AR is the idea of having to use explicit joins with raw SQL when you need to filter a table through another. Would this be alleviated by the generic aliases discussed here (such as @self and @foreign)?

What's the problem with using something like ->with('relation_name') or ->together()? As a system's developer (and not Yii Core developer) I see those two approaches MUCH easier to be used, as they give more readability and flow to the AR querying code.
0

Share this topic:


  • (7 Pages)
  • +
  • « First
  • 5
  • 6
  • 7
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users