thanks...
Got it now with
'Post' => array('fields' =>array('Post.title' , 'Post.created' ,
SUBSTR('description', 0, 50) , 'Post.key'),
'limit' => 5,
))
-----Original Message-----
From: Miles J [mailto:[email protected]]
Sent: June-07-09 5:57 PM
To: CakePHP
Subject: Re: Limit characters?
No the function.
SUBSTR(Post.description, 0, 50)
On Jun 7, 1:21 pm, "Dave Maharaj :: WidePixels.com"
<[email protected]> wrote:
> Still same thing....
>
> 'Post' => array('fields' =>array('Post.title' , 'Post.created' ,
> 'substr(Description, 0, 50)' , 'Post.key'),
> 'limit' => 5,
> ))
>
> Returns this query:
> SELECT `Post`.`title`, `Post`.`created`, substr(Post.Description, 0,
> 50), `Post`.`key`, `Post`.`user_id`, `Post`.`id` FROM `posts` AS
> `Post` WHERE `Post`.`user_id` = (6) LIMIT 5
>
> [0] => Array
> (
> [substr(Post.Description, 0, 50)]
> =>
> )
>
> -----Original Message-----
> From: Miles J [mailto:[email protected]]
> Sent: June-07-09 5:34 PM
> To: CakePHP
> Subject: Re: Limit characters?
>
> It has to be capitalized.
>
> On Jun 7, 11:03 am, "Dave Maharaj :: WidePixels.com"
> <[email protected]> wrote:
> > Nope....no go
>
> > I have 'Post' => array('fields' =>array('Post.title' ,
> > 'substr(description , 0 , 50)' )
>
> > Tried:
> > 'Post' => array('fields' =>array('Post.title' ,
> > 'substr(Post.description , 0 , 50)' )
>
> > 'Post' => array('fields' =>array('Post.title' ,
> > substr('Post.description' , 0 , 50) )
>
> > The array spits out
>
> > [0] => Array
> > (
> > [substr(description , 0
> > , 50)] =>
> > )
>
> > -----Original Message-----
> > From: Rick [mailto:[email protected]]
> > Sent: June-07-09 10:21 AM
> > To: CakePHP
> > Subject: Re: Limit characters?
>
> > In your select you can do something like this:
>
> > [code]
> > $this->Model->find('xxx', array(
> > fields => 'substr(description, 0, 50)', ...
> > [/code]
>
> > On Jun 6, 1:20 pm, "Dave Maharaj :: WidePixels.com"
> > <[email protected]> wrote:
> > > Can cake limit the return on characters in a query?
>
> > > I have in view
>
> > > <?php echo substr($additional_posts['description'],0,50);?>
>
> > > to display the first 50 characters in the post descriptions to
> > > give a brief description to a user...but rather than pulling the
> > > whole description in the find then displaying limited characters,
> > > can i limit the description to 50 characters in the find query?
>
> > > Thanks,
>
> > > Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---