Re: Generate List of Full Names
try this: $this-Author-generateList(null, null, null, null, {n}.Author.last_name {n}.Author.first_name); On Dec 11, 2007 9:46 AM, aniston [EMAIL PROTECTED] wrote: Just an indicator that might help you, its an example on db column merging with concat http://groups.google.com/group/cake-php/msg/1a8b39d9062c21f3 (hth) aniston On Dec 11, 3:15 am, Gould, Adrian [EMAIL PROTECTED] wrote: Problem: The table AUTHORS has the fields (id, given_name, last_name, created, modified) but no title field. I wish to fill a select box with the id and FULL NAME that is created by merging last_name and first_name. in SQL you'd do soemthing like: SELECT id, CONCAT( last_name, ', ', first_name) AS title FROM authors how can I use this form of query in CakePHP to generate the list using: $this-set('authors', $this-Book-Author-generateList()); Thanks\ Adrian --- Adrian Gould Lecturer in IT / Network Engineering / Multimedia Business Finance Computing [Midland Campus] Swan TAFE PO BOX 1336, Midland WA 6936 Phone: (08) 9267 eMail: [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 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 -~--~~~~--~~--~--~---
Re: Generate List of Full Names
hi I had a similar problem. But I took another approach. I added afterFind function in my model. AfterFind gets called after every query and there I have the rule to calculate full name..below is a sample code function afterFind($results) { foreach ($results as $key = $val) { if(array_key_exists('Author', $val)){ $results[$key]['Author']['full_name'] = my_logic_for_getting_full_name($val['Author']) }else{ $results[$key]['full_name'] = my_logic_for_getting_full_name($val); } } return $results; } hope this helps bingo On Dec 11, 3:28 am, Tomas Rimelis [EMAIL PROTECTED] wrote: try this: $this-Author-generateList(null, null, null, null, {n}.Author.last_name {n}.Author.first_name); On Dec 11, 2007 9:46 AM, aniston [EMAIL PROTECTED] wrote: Just an indicator that might help you, its an example on db column merging with concat http://groups.google.com/group/cake-php/msg/1a8b39d9062c21f3 (hth) aniston On Dec 11, 3:15 am, Gould, Adrian [EMAIL PROTECTED] wrote: Problem: The table AUTHORS has the fields (id, given_name, last_name, created, modified) but no title field. I wish to fill a select box with the id and FULL NAME that is created by merging last_name and first_name. in SQL you'd do soemthing like: SELECT id, CONCAT( last_name, ', ', first_name) AS title FROM authors how can I use this form of query in CakePHP to generate the list using: $this-set('authors', $this-Book-Author-generateList()); Thanks\ Adrian --- Adrian Gould Lecturer in IT / Network Engineering / Multimedia Business Finance Computing [Midland Campus] Swan TAFE PO BOX 1336, Midland WA 6936 Phone: (08) 9267 eMail: [EMAIL PROTECTED] Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Generate List of Full Names
Problem: The table AUTHORS has the fields (id, given_name, last_name, created, modified) but no title field. I wish to fill a select box with the id and FULL NAME that is created by merging last_name and first_name. in SQL you'd do soemthing like: SELECT id, CONCAT( last_name, ', ', first_name) AS title FROM authors how can I use this form of query in CakePHP to generate the list using: $this-set('authors', $this-Book-Author-generateList()); Thanks\ Adrian --- Adrian Gould Lecturer in IT / Network Engineering / Multimedia Business Finance Computing [Midland Campus] Swan TAFE PO BOX 1336, Midland WA 6936 Phone: (08) 9267 eMail: [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 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 -~--~~~~--~~--~--~---
Re: Generate List of Full Names
Just an indicator that might help you, its an example on db column merging with concat http://groups.google.com/group/cake-php/msg/1a8b39d9062c21f3 (hth) aniston On Dec 11, 3:15 am, Gould, Adrian [EMAIL PROTECTED] wrote: Problem: The table AUTHORS has the fields (id, given_name, last_name, created, modified) but no title field. I wish to fill a select box with the id and FULL NAME that is created by merging last_name and first_name. in SQL you'd do soemthing like: SELECT id, CONCAT( last_name, ', ', first_name) AS title FROM authors how can I use this form of query in CakePHP to generate the list using: $this-set('authors', $this-Book-Author-generateList()); Thanks\ Adrian --- Adrian Gould Lecturer in IT / Network Engineering / Multimedia Business Finance Computing [Midland Campus] Swan TAFE PO BOX 1336, Midland WA 6936 Phone: (08) 9267 eMail: [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 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 -~--~~~~--~~--~--~---