Just to clarify, the solution works for any association, we just use
hasOne to trick cake into building a JOIN query, but as you see in the
example we are using models from hasMany and HABTM.
On Sep 9, 1:21 pm, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
Sorry, I didn't mention that I use
Hello newsgroup!
I have defined the following associations in my models:
PostModel: Post _hasMany_ Comments
var $hasMany = array(
'Comment' = array(
'className' = 'Comment',
'conditions' = '',
'foreignKey' = 'post_id',
)
);
CommentModel: Comment _belongsTo_ User
var
Hi,
This should be solvable with with Containable behavior. Or - if you want to
do this with just one query - use the infos you can find in teknoids blog:
http://teknoid.wordpress.com/2008/07/17/forcing-an-sql-join-in-cakephp/
Those infos are also present in the manual for 1.2.
2008/9/9 [EMAIL
Sorry, I didn't mention that I use cakephp 1.1!
I've read the post on teknoids blog. The disadvantage is, that this
solution only works for hasOne associations and not for hasMany.
But: I used the idea mentioned there and tried to create a LEFT JOIN
in the sql-query.
I found out, that this is
You just need to set recursive to 2.
On Sep 9, 8:20 am, [EMAIL PROTECTED] [EMAIL PROTECTED]
wrote:
Hello newsgroup!
I have defined the following associations in my models:
PostModel: Post _hasMany_ Comments
var $hasMany = array(
'Comment' = array(
'className' = 'Comment',