Hello Everybody!

I'm learning CakePHP since few days and got problems now. I'm
rewritting my portal to CakePHP. Sorry for any bad things, this is my
first question to google groups ever :-)

I got following query:
select avg(Ratings.vote) as rating, count(Ratings.username) as votes,
title, type, Albums.band_name, Albums.salt, Albums.id as id,
release_date from portal_albums AS Albums join portal_albums_ratings
AS Ratings on Albums.id=Ratings.album_id group by Albums.id order by
rating DESC, votes DESC LIMIT 3

Also I put following function in app_model.php:
        function afterFind($results, $primary=false)
        {
                if($primary == true) {
                        if(Set::check($results, '0.0')) {
                                $fields = array_keys( $results[0][0] );
                                foreach($results as $key=>$value) {
                                        foreach( $fields as $fieldName ) {
                                                
$results[$key][$this->alias][$fieldName] = $value[0]
[$fieldName];
                                        }
                                        unset($results[$key][0]);
                                }
                        }
                }
                return $results;

So now, I can display results of my custom query by using $var['Model']
['field']

Is there any easy way to convert this query to use $this->find()
method? I'm quering currently using $this->query() and it works
perfectly but just thinking if I should use find method.

What's your opinions?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en

Reply via email to