[Solar-talk] Added notes on working with Models/Records to thewiki
Kilbride, James P.
James.Kilbride at gd-ais.com
Wed Nov 14 07:55:08 CST 2007
Do you have to define the columns of the table in the _setup for the
magic fetchs to work or will it use reflection to do that?
James Kilbride
-----Original Message-----
From: solar-talk-bounces at lists.solarphp.com
[mailto:solar-talk-bounces at lists.solarphp.com] On Behalf Of Rodrigo
Moraes
Sent: Wednesday, November 14, 2007 3:19 AM
To: solar-talk at lists.solarphp.com
Subject: Re: [Solar-talk] Added notes on working with Models/Records to
thewiki
On Nov 13, 2007 12:44 PM, Oscar M. wrote:
> I've been lurking on the list for a while, and over the last 2 weeks
> have finally started playing with the latest Solar code. I banged my
> head a little trying to get the Model/Record stuff setup correctly.
> As a result added my notes about how to make it work to the wiki
> <http://solarphp.org/wiki/tutorials/SettingUpModels>. I hope it can
> be a useful addition to Solar's documentation, especially for helping
> newcomers feel productive quickly.
Very nice and clear, thank you. :)
I'm thinking to add some notes about the magic fetch* methods, i.e.
you can call "fetchAllByStatus(1)" and the method doesn't necessarily
need to exist in your model. When called, in this example it'd return
all records with the column "status" = 1. It is also available for
fetchOne and you can define *two* column values. Some examples:
$record = $model->fetchOneByStatus(1);
$record = $model->fetchOneByStatusAndName(1, 'foo');
$collection = $model->fetchAllByName('foo');
$collection = $model->fetchAllByNameAndOtherName('foo', 'bar');
An optional array with parameters for the fetch (like those we use for
normal fetch's) can be added as a last parameters for all the examples
above:
$record = $model->fetchOneByStatus(1, $params);
$record = $model->fetchOneByStatusAndName(1, 'foo', $params);
... etc.
These are very handy for common/basic/quick fetch's we do all the time.
-- rodrigo
_______________________________________________
Solar-talk mailing list
Solar-talk at lists.solarphp.com
http://mailman-mail3.webfaction.com/listinfo/solar-talk
More information about the Solar-talk
mailing list