I hear you. I'm the guy that tweaked the book to show how to do the same thing in postgres.
Cake's DB layer is unaware of the differences in how string concatenation works in the various DBs, though I suspect most would find it desirable to have that change. I guess you could write a method in app_model.php that was aware of how to concat a string in each supported database, then send it a list of fields and a separator and have it make the virtualField. As a postgresql user who will probably never touch mysql (or anything else, most likely) I'm too lazy to do it myself. Matt On Fri, May 7, 2010 at 08:19, Sunny <[email protected]> wrote: > Virtual fields which is described at > http://book.cakephp.org/view/1608/Virtual-fields > This makes the code depends on the database. For example this piece of > code would only work for MySQL > > var $virtualFields = array( > 'full_name' => 'CONCAT(User.first_name, " ", User.last_name)' > ); > > I'm looking for a more database agnostic approach. The reason is I'm > still not sure what database I'll be using in production so I want to > keep my code as much database agnostic as possible. > > Any suggestions? > > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > You received this message because you are subscribed to the Google Groups > "CakePHP" 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 > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. You received this message because you are subscribed to the Google Groups "CakePHP" 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
