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

Jump to content

  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

Status update: ActiveRecord

#21 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 27 March 2012 - 03:42 PM

@phpnode

I posted with these awesome ideas in mind. I believe that they'll make it to the core. I just don't know how. Maybe you're right.
0

#22 User is offline   Rodrigo Coelho 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 665
  • Joined: 05-August 10
  • Location:Rio de Janeiro, Brazil

Posted 28 March 2012 - 10:51 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.


This would be so nice for the collection object when dealing with (and saving) related models.
0

#23 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 28 March 2012 - 04:59 PM

It would be really interesting to see comparisons between old AR and new AR.
It looks like it's going to be a lot leaner, right?
In terms of performance, memory, etc. I mean.
"Less noise - more signal"
0

#24 User is offline   Mike 

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

Posted 29 March 2012 - 01:34 AM

Really nice stuff. What about validation rules? Any changes here?

I wasn't very happy that in 1.1.x the definition of validation rules was combined with the definition of safe attributes (it was separate in 1.0.x). For big models with several scenarios it made rules() bloated. But i could override getSafeAttributeNames() to keep things a bit more separated. Will this still be possible? Or did it also change completely?
0

#25 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 29 March 2012 - 09:09 AM

@Psih: I'm not sure if this extension still works. It allows you to use native drivers.

@Mike: No, validation rules are largely unchanged. If you have many scenarios in a model, for better organization you could put the rules for different scenarios in different functions and then merge them in rules().
0

#26 User is offline   Mike 

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

Posted 30 March 2012 - 01:22 AM

View Postqiang, on 29 March 2012 - 09:09 AM, said:

@Mike: No, validation rules are largely unchanged. If you have many scenarios in a model, for better organization you could put the rules for different scenarios in different functions and then merge them in rules().


Well, that's not quite the same: I really want a separation of safe attributes from validation rules. As long as that's still possible (overriding getSafeAttributeNames or similar), i'm happy. I just don't want to list different sets of scenarios on every rule all the time as it makes my validation code very lengthy.
0

#27 User is offline   Psih 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 115
  • Joined: 30-June 10

Posted 30 March 2012 - 05:26 AM

View Postqiang, on 29 March 2012 - 09:09 AM, said:

@Psih: I'm not sure if this extension still works. It allows you to use native drivers.

I've checked it, yes. That's the first thing that come up. But essentially it is PDO implementation to the letter without exposing any additional functionality to CDbConnection, so you can't use any driver-specific functionality at all. It's just a drop-in emulation if there is no PDO available.
I'm willing to try to do something about this for the Yii 2, but I need access to the source to see what can be or can't be done about it :unsure:
0

#28 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,902
  • Joined: 04-October 08
  • Location:DC, USA

Posted 30 March 2012 - 09:05 AM

It is possible to expose driver-specific functions through this PDO protocol. The new DB connection class is largely the same as 1.1. If your implementation of this PDO emulation is complete, we may consider including it into the core. Since we are still actively developing 2.0, we won't release the source code to public before it is relatively stable.
0

#29 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 30 March 2012 - 10:27 AM

Are there any plans for intercepting events (similar to how filters work now for controllers)? Because then we could implement things like identity maps as a behavior. (Got to admit: That's for now the only use case I can imagine ...)
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
1

#30 User is offline   Psih 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 115
  • Joined: 30-June 10

Posted 30 March 2012 - 11:31 AM

View Postqiang, on 30 March 2012 - 09:05 AM, said:

It is possible to expose driver-specific functions through this PDO protocol. The new DB connection class is largely the same as 1.1. If your implementation of this PDO emulation is complete, we may consider including it into the core. Since we are still actively developing 2.0, we won't release the source code to public before it is relatively stable.

Ok, i will do the work in next few week and will see if it works out fine.
0

#31 User is offline   johonunu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 26-November 10

Posted 01 April 2012 - 05:06 AM

New Active Record class looks very nice and clean.
I like asArray() method, similar to what CakePHP is doing.
I will only miss STAT relations :(
0

#32 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 2,601
  • Joined: 10-October 10
  • Location:Denmark

Posted 01 April 2012 - 07:59 AM

I am sure that either the Yii team or the community - or even both - will provide an alternative to STAT. :)
"Less noise - more signal"
0

#33 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 01 April 2012 - 02:12 PM

I'm really hoping that the equivalent of STAT will be:

$model->hasManyOrManyManyRelation->count();
1

#34 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 02 April 2012 - 12:39 PM

View PostDa:Sourcerer, on 30 March 2012 - 10:27 AM, said:

Are there any plans for intercepting events (similar to how filters work now for controllers)? Because then we could implement things like identity maps as a behavior. (Got to admit: That's for now the only use case I can imagine ...)

Hm, actually ... Caching for active records could be implemented as a behavior this way, too.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#35 User is offline   Haensel 

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

Posted 03 April 2012 - 06:44 AM

@phpnode: I agree. Using relations to do a count() felt wrong anyway. I would expect relations to always return a single AR object or an array of objects, nothing else
0

#36 User is offline   soso 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 24-February 10

Posted 11 April 2012 - 07:05 AM

Hello,

Do you think of updating the scenario logic?

For example, v1 implementation if you have a rule for the default scenario for a field as 'required' then it isn't possible to make the field not required in a custom scenario. I bumped into something like this, I simply needed the field to not be required anymore in a custom scenrario, something like 'safe' only.

Thanks.
0

#37 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 22 April 2012 - 08:38 AM

@qiang - Please can the ActiveQuery class have a getDataProvider() method?

e.g.

User::find()->someScope()->anotherScope()->getDataProvider();


It would also be really useful to have an easy way of getting a data provider for related records:

$user->photos->getDataProvider(); // photos is a has_many or many_many relation

2

#38 User is offline   samdark 

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

Posted 22 April 2012 - 04:59 PM

Isn't it better to be able to pass an instance of ActiveFinder to the contructor of DataProvider? This way we'll not have a situation that lower level AR depends on higher level data provider.
Yii 1.1 Application Development Cookbook

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

#39 User is offline   phpnode 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 141
  • Joined: 18-April 11

Posted 23 April 2012 - 02:54 AM

@samdark - perhaps, but in that case we should also be able to pass an ActiveRelation to the dataprovider's constructor too, e.g.

$dataProvider = new ActiveDataProvider($user->photos);

1

#40 User is offline   dyulax 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 26-May 11
  • Location:Brazil

Posted 30 April 2012 - 10:33 AM

I think here is not the best place, but anyway:

May be the search() method could be generated working with dates, times, and datetime attributes (+ i18n) and case insensitive strings (john will return JOHN).
Do what thou wilt shall be the whole of the Law.
0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • Last »
  • 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