Re: Count (return as a number) associated data.

2012-06-18 Thread Joris Vaesen
count($var['Post'])

On Tuesday, 19 June 2012 00:24:15 UTC+2, JonStark wrote:
>
> Sorry, incomplete :
>
> It will produce an array like :
>
> array(
>   'User' => array(
>   'password' => '*',
>   'id' => '2',
>   'username' => 'test',
>
>   ),
>   'Post' => array(
>   (int) 0 => array(
>   'id' => '36',
>   'user_id' => '2', (...)
>
>   )
>   ),
>
>
> How can I display the number of Posts this user have ? (in this example 1) 
> ?
>
> Thanks a lot.
>
> Le mardi 19 juin 2012 00:21:25 UTC+2, JonStark a écrit :
>>
>> Let's say USer hasMany Post.
>>
>> If i debug my user it will produce an array like :
>>
>> User
>>
>>

-- 
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


Caching part of view and user-specific sidebar problem

2012-06-18 Thread Joris Vaesen
I've build an application with a where where users can see multiple items.
These items are sorted by pagination.

Because of the big amount of items per page would i like to do some caching.
Because the page is using pagination, I can't cache the query.

So I was thinking about caching the view, which works very well but one 
thing:
The sidebar on the page is user-specific and may not be cached.
So I separated this part in an element and used the  html 
comment technique.

Now is my problem that i can't get any data in this element. The data for 
this element may not be cached.
The only oppertunity thought of was doing some queries in de element to get 
recent data.

But is this in any way possible to query from an element?

-- 
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