Learn, Share, Build

227
October 05, 2017, at 3:19 PM

I am having a trouble in executing query as follow

$result = $this->Booking->find('all', array('conditions'=>$conditions,                        
                        'joins' => array(
                                            array(
                                                'table' => 'users',
                                                'alias' => 'user',
                                                'type' =>  'INNER',
                                                'conditions' => array(
                                                    'user.id = Booking.userId',                                                   
                                                )
                                            ),
                                            array(
                                                'table' => 'venues',
                                                'alias' => 'venue',
                                                'type' =>  'INNER',
                                                'conditions' => array(
                                                    'venue.id = Booking.venueId'                                                   
                                                )
                                            ),
                                            array(
                                                'table' => 'venue_types',
                                                'alias' => 'venueType',
                                                'type' =>  'INNER',
                                                'conditions' => array(
                                                    'venueType.id = Booking.venueType',                                                   
                                                )                                                       
                                            ),
                                    ),
                        'fields' => array('user.id','user.name','user.imagePath','venueType.*', 'Booking.*', 'venue.*', 'venue.reviewsCount AS (SELECT count(*) FROM reviews WHERE venueId = venue.id)'), 
                        'order' => array('Booking.created DESC'),
                        'limit' => 20,
                        'offset' => $offset * 20
        ));

It is giving me error at

 'venue.reviewsCount AS (SELECT count(*) FROM reviews WHERE venueId = venue.id)

Can anyone pls tell me how to add virtual fields if we use join like this

Rent Charter Buses Company
READ ALSO
Learn, Share, Build

Learn, Share, Build

This seems to be a fairly simple issue, but I am not able to get it working

235
Learn, Share, Build

Learn, Share, Build

I have one table in which i store document properties and for each new document with a specific properties i need to increment integer which identifies that documentThis is my select query:

246
Learn, Share, Build

Learn, Share, Build

I'm sure this is a duplicated topic, but I simply cannot get it done: I like to restore my database dump to MySQL container in run time, without modifying the docker-composeyml file

231
Learn, Share, Build

Learn, Share, Build

Here is the query belowPlease suggest how can I simplify the same:

259