Remember as well you could use an SQL view to achieve things like
this, making your code lots cleaner.
Remember you can also dynamically change the table used by a model, so
you can switch from the real table to the view for particular queries,
then switch back (No idea if that's considered good practice!).

On Jan 18, 9:55 am, grigri <[EMAIL PROTECTED]> wrote:
> Whether using database functions like CONCAT(), or php code, I agree
> it would be nice to handle fields in a simple, easy manner. In a
> project a while ago I was storing a comma-delimited list in a database
> field [I had my reasons] and explode()ing it in afterFind. The
> afterFind code, to handle all possible ways it could be called, was
> pretty horrendous.
>
> It would be cool to have a sort of inverse Model::deconstruct() called
> for each retrieved row, although I suppose you could build that sort
> of functionality with a behavior, and hide all the nasty code inside
> the behavior's afterFind, and put the callback in the model. Hmm...
> sounds like it could work.
>
> On Jan 18, 9:43 am, AD7six <[EMAIL PROTECTED]> wrote:
>
> > On Jan 18, 10:16 am, Flipflops <[EMAIL PROTECTED]> wrote:
>
> > > Hi AD7six
>
> > > I like you answer -  letting the database use CONCAT leaves your code
> > > nice and clean, how exactly are you suggesting to do it though?
>
> > Add it to your field list.
>
> > > Can you append it to the model in some way when you use a built in
> > > method (e.g. findAll)
>
> > Yup. see an example in 
> > here:https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/beh...
> > // see how MAX() is used.
>
> > > or were you suggesting creating a custom query
> > > function  in the model and then calling that instead of a built in
> > > method (e.g. $this-->MyModel->MyQuery())
>
> > Nope.
>
> > > I've got a horrible suspicion that I've been writing a whole load of
> > > unnecessary code, or does this only apply to 1.2 (I've only used 1.1
> > > so far).
>
> > I doubt you are alone if that's true - if I don't know what's
> > possible, I go with what works, and then spend ages doing purist code
> > optimizations ;).
>
> > hth,
>
> > AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to