Yes that's what I try first:
$tests=$this->Resultat->findAll(null,
array( 'id',
'IF ( message IS NULL , NULL ,
1)'),
null,
null,
null,
-1);
pr($tests);
Give me :
[1] => Array ( [Resultat] => Array ( [id] => 103 ) [0] => Array ( [IF (
message IS NULL , NULL , 1)] => ) ) [2] => Array ( [Resultat] => Array (
[id] => 104 ) [0] => Array ( [IF ( message IS NULL , NULL , 1)] => 1 ) )
The array is not well formated : the if statement is not inserted in the
Resultat array.
On 2/8/07, Ámon Tamás <[EMAIL PROTECTED]> wrote:
>
>
> [EMAIL PROTECTED] wrote:
> > Can you give me a litte bit more explaination on how to make it in the
> > model?
> Somethign like this a new function in the resultstat model:
>
> function sg() {
> return $this->findAll("a=b", "Resultat.id , IF ( Resultat.message IS
> NULL , NULL , 1)");
>
> look the findAll in the manual (I don't try it, but I hope it is works).
> }
> >
> > thanks
> >
> > On 8 fév, 12:23, Ámon Tamás <[EMAIL PROTECTED]> wrote:
> >> [EMAIL PROTECTED] wrote:
> >>> I'm trying to execute a query like this one :
> >>> SELECT Resultat.id , IF ( Resultat.message IS NULL , NULL , 1)
> >>> FROM `resultats` AS `Resultat`
> >>> WHERE ...
> >>> or
> >>> SELECT Resultat.id , LENGTH(Resultat.message)
> >>> FROM `resultats` AS `Resultat`
> >>> WHERE ...
> >>> and to return the result as Array of records
> >>> I know this is mysql specific fonction and that wouldn't work on
> >>> another dbengine but this is a performance problem : the message field
> >>> is a text one and could be very long and everything I need to know if
> >>> it is empty or not.
> >>> I can do this by merging 2 result but that's not really like usual
> >>> cake's magic.
> >> You can make it in model functions, but this is working only with
> mysql.
> >> Maybe you can make more models if you want to use with more db engines.
> >>
> >> --
> >> Ámon Tamáshttp://linkfelho.amon.hu
> >
> >
> > >
> >
>
>
> --
> Ámon Tamás
> http://linkfelho.amon.hu
>
>
> >
>
--
Luigi
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---