Hello
I'm trying to use finderQuery for a hasMany relationship between tables
in cake to get Ratings automatically when I view an Entry.. anyhow, I
use this:
var $hasMany = array (
'WikiRating' => array (
'className' => 'WikiRating',
'foreignKey' => 'entry_id',
'dependent' => true,
'exclusive' => true,
'finderQuery' => 'SELECT ( SELECT count(*)
FROM wiki_ratings AS
WikiRating WHERE WikiRating.entry_id = {$__cakeID__$} ) AS num_votes,
AVG(WikiRating.rating) AS avg_rating FROM wiki_ratings AS WikiRating
WHERE WikiRating.entry_id = {$__cakeID__$} LIMIT 1'
)
);
but am getting an odd error which causes an error in dbo_source:
Notice: Undefined index: WikiRatings in c:\documents and
settings\morris\Desktop\houseparty_alpha\alpha_build_svn\web\cake\libs\model\datasources\dbo_source.php
on line 709
Notice: Undefined index: WikiRatings in c:\documents and
settings\morris\Desktop\houseparty_alpha\alpha_build_svn\web\cake\libs\model\datasources\dbo_source.php
on line 716
After a closer look, it seems like the query is executing OK but the
result it is getting is [0][0][num_votes] and [0][0][avg_rating]...
which when merging cake doesnt like, since it is looking for
[0][ModelName][...] etc..
SO, I'm wondering if any of you may have run into something like this,
or know how I can force my result to work as cake wants it.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Cake PHP" 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
-~----------~----~----~----~------~----~------~--~---