Monday, December 9, 2013

Re: Virtual Field + Concat and find problems

Not directly, but with a behavior I did it...
In the conditions instead of using
'local'=>'Cascavel - PR'

My behavior check if is a virtualfield and turns the condition query into this:
"CONCAT({$this->alias}.city,' - ',{$this->alias}.state)"=>"Cascavel - PR"


for example, 

Em quinta-feira, 5 de dezembro de 2013 00h57min03s UTC-2, Simon Males escreveu:
You cannot search a virtualField... it is virtual.

You'll have to search the columns directly.

On Thu, Dec 5, 2013 at 3:17 AM, André Luis <cava...@live.com> wrote:
> Hi everyone, i have a table "clients" wich the model is "Client"... and in
> my table I have the fields "city" and "state" and others... Also I have the
> following virtualfield:
> public $virtualFields = array(
>     'local'=>"CONCAT(Client.city,' - ',Client.state)",
> );
>
> When i use a find "all" with the conditions 'Client.local'=>'Cascavel - PR'
> it works perfectly... but if I try to find with the conditions
> 'Client.local'=>array('Cascavel - PR','Toledo - PR'), cake gives me an error
> saying that the field Client.local doesnt exists...
>
> Does anyone know where i am wrong??
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+u...@googlegroups.com.
> To post to this group, send email to cake...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Simon Males

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

No comments: