[Solar-talk] Solar_Sql_Model Feedback

Paul M Jones pmjones at ciaweb.net
Wed Jul 11 16:20:31 CDT 2007


Hi Ian,

> I've been messing around with the model system included in Solar and
> it works pretty well, especially letting the relations setup joins
> automatically. One issue however that I couldn't get around too easily
> is when dealing large collections (it isn't even that big, 50 records)
> that include eager loaded records. The data is already there, but when
> getting around to iterating it generates many record objects, and this
> slows things down pretty significantly, especially if you have more
> relations.

I don't have satisfactory answers for you on this yet, other than to  
say "I know it's not very good right now and I'll be working on it  
some more".  The basic problem is that Solar_Sql_Model is still in  
its early stages, and eager-loading (among other things) is not very  
smart yet, as you have noticed.


> Is there a way to just iterate through the data, and
> optionally load the row objects if they are needed?

In theory, if you don't specify eager-loading, it should only attempt  
to load the related record from the database when you ask for the  
corresponding property.  That is, if you defined a related 'foo', it  
should stay NULL until you ask for $record->foo, at which time the  
__get() magic method hits the database and populates 'foo'.  (Hope  
that makes sense).


> Generating that
> many objects when in most cases you just want to spit out the data
> (which can be loaded ahead of time by specifying the eager stuff)
> seems like overkill to me... I mean, I could just add a "data()"
> method that returns _data, but then that would mean I'd have to access
> the related records by double underscore which seems pretty
> counter-intuitive.

Also in theory, you should be able to get to the related records just  
by accessing the property normally; that is, you shouldn't have to  
call the __get() or __getFoo() method, just the $foo property.


> Also, maybe you could consider loading the select objects through
> dependencies possibly? In case I'm using a custom Solar_Sql_Select?

That's a good idea -- can you enter it as a feature request for me so  
I don't forget?

   <http://solarphp.com/trac/newticket>

Thanks for the feedback, please let me know if this was helpful or not.


--

Paul M. Jones  <http://paul-m-jones.com>

Solar: Simple Object Library and Application Repository
for PHP5.  <http://solarphp.com>

Join the Solar community wiki!  <http://solarphp.org>

Savant: The simple, elegant, and powerful solution for
templates in PHP.  <http://phpsavant.com>




More information about the Solar-talk mailing list