Re: Question about $virtualFields
On Tue, Mar 15, 2011 at 8:05 PM, dreamingmind wrote: > Perhaps the fields involved in assembly of the virtualField need to be > in the field list for the find. No, that's not the case. Given a table with columns id, first_name, last_name we can do: SELECT id, CONCAT(first_name, ' ', last_name) AS full_name FROM users; We don't need to do: SELECT id, first_name, last_name, CONCAT(first_name, ' ', last_name) AS full_name FROM users; -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Question about $virtualFields
Perhaps the fields involved in assembly of the virtualField need to be in the field list for the find. Don On Mar 15, 2:48 am, heohni wrote: > Hi, > > I am using the $virtualFields when I do a paginate for a find. > But it works only when I have not restrictions on the fields. > > var $virtualFields = array( > 'memberfullname' => 'CONCAT(Member.mitg_nachname, ", ", > Member.mitg_vorname)', > ); > > As soon as I limit the fields, I can't select the virtualFields > anymore. > > If I do it manually (DRY??) like fields => > array('CONCAT(Member.mitg_nachname, ", ", Member.mitg_vorname) as > memberfullname') > > I get as result an array like > [Member] => Array > ( > [id] => 5 > [mitg_nummer] => 586858 > [mitg_status] => 1 > ) > [0] => Array > ( > [memberfullname] => xx, xx > > which is stupid, as the memberfullname is not under the [Member] > Array. > > Any ideas how to get arround? -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Question about $virtualFields
On Tue, Mar 15, 2011 at 5:48 AM, heohni wrote: > Hi, > > I am using the $virtualFields when I do a paginate for a find. > But it works only when I have not restrictions on the fields. > > var $virtualFields = array( > 'memberfullname' => 'CONCAT(Member.mitg_nachname, ", ", > Member.mitg_vorname)', > ); > > As soon as I limit the fields, I can't select the virtualFields > anymore. > > If I do it manually (DRY??) like fields => > array('CONCAT(Member.mitg_nachname, ", ", Member.mitg_vorname) as > memberfullname') > > I get as result an array like > [Member] => Array > ( > [id] => 5 > [mitg_nummer] => 586858 > [mitg_status] => 1 > ) > [0] => Array > ( > [memberfullname] => xx, xx > > which is stupid, as the memberfullname is not under the [Member] > Array. > > Any ideas how to get arround? I think LipeDjow's answer may be correct but the answer to the second part is here: http://nuts-and-bolts-of-cakephp.com/2008/09/29/dealing-with-calculated-fields-in-cakephps-find/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
Re: Question about $virtualFields
Not sure, but try this: array('CONCAT(Member.mitg_nachname, ", ", Member.mitg_vorname) as `Member.memberfullname`') HTH LipeDjow -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php