Try this:

http://openpaste.org/en/3929/

Use it like this:

class Something extends AppModel {
  // ...
  var $actsAs = array('Farmer');
  // ...
}

// assume model Something has fields 'one' and 'two' but NOT a field
called 'three':

function action() {
  // These lines all do the same thing:
  $blurb = $this->Something->find('all', array('fields' =>
'Something.*, CONCAT(Something.one, Something.two) AS three'));
  $blurb = $this->Something->find('all', array('fields' =>
'Something.*, CONCAT(Something.one, Something.two) AS
`Something`.`three`'));
  $blurb = $this->Something->find('all', array('fields' =>
array('Something.*', 'CONCAT(Something.one, Something.two) AS
`Something`.`three`'));
  $blurb = $this->Something->find('all', array('fields' =>
array('Something.*', 'CONCAT(Something.one, Something.two)' =>
'`Something.three`'));
}

// you'll get:

Array
(
    [0] => Array
        (
            [Something] => Array
                (
                    [id] => 1
                    [one] => foo
                    [two] => bar
                    [three] => foobar
                )

        )
)

I haven't fully tested it, but it seems to work ok.

On Nov 16, 11:27 am, "Ricardo Valfreixo" <[EMAIL PROTECTED]> wrote:
> Hey Axl,
>
> I guess you're stuck there. I haven't figured out a way to do it without
> hacking the base code directly. Remember that it's a pre-beta version. Maybe
> it'll get a workaround or some other solution. For now, i guess that's the
> only way to do it.
>
> Zen
>
> On Nov 16, 2007 11:22 AM, Axl <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > On Nov 14, 3:10 pm, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> > > Don't forget that there is an 'alpha with extreme prejudice' version
> > > of the Cake 1.2 manual over athttp://tempdocs.cakephp.org
>
> > I've studied it. And I've also found an answer to my question. But
> > it's not in the docs but here:
>
> >https://trac.cakephp.org/ticket/276
>
> > The solution presented there seems less than elegant though. Is there
> > really no way of using 'AS' in the Cakephp Model functions without
> > changing the base code?
>
> > Greets,
> > Axl
>
> --
> ----------------- ----------------- ---------------
> name: Ricardo Valfreixo
> e-mail: [EMAIL PROTECTED]
> msn: [EMAIL PROTECTED]
> ----------------- ----------------- ---------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
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