Try something like: SUBSTR(Post.description,1,50) as strPart, this will work :-) "note that the string starts from 1 instead of 0"
On Mon, Sep 21, 2009 at 9:16 PM, Dave Maharaj :: WidePixels.com < [email protected]> wrote: > > Changed the quotes. > > Now I end up with > > Array > ( > [title] => Greener Plan-it! > [created] => 2009-07-16 13:28:59 > [id] => 8197d5 > [country_id] => 54 > [state_id] => 7 > [Post] => Array > ( > [0] => Array > ( > [SUBSTR(description, 0, 50)] => > ) > > ) > > ) > > There is a description to be pulled but nothing shows up. > > Ideas? > > Thanks > > Dave > > -----Original Message----- > From: Miles J [mailto:[email protected]] > Sent: September-21-09 3:20 PM > To: CakePHP > Subject: Re: Select only first 50 characters? > > > Your quotes are wrong: > > 'fields' =>array( > 'Post.title', > 'Post.created', > 'SUBSTR(description, 0, 50)', > 'Post.id'), > > On Sep 21, 10:21 am, "Dave Maharaj :: WidePixels.com" > <[email protected]> wrote: > > When doing a query how can i pull only a desired number of characters > > from a field? > > > > I have: > > > > 'fields' =>array( > > 'Post.title', > > 'Post.created', > > SUBSTR('description', 0, 50), > > 'Post.id'), > > > > But this is wrong, > > > > Ideas? > > > > Dave > > > > > -- http://phpirate.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
