Thursday, August 8, 2013

Complex query not possible using Cakephp?

Hello everyone,

I have a complex query for summarizing data that looks like:

$sql = 'SELECT
                                  severity,
                                  SUM( IF( c.name = "ABC", 1, 0 ) ) AS "ABC",
                                  SUM( IF( c.name = "XYZ", 1, 0 ) ) AS "XYZ",
FROM events s
                                                        INNER JOIN classes c ON c.id = s.class_id
                                                        group by severity
                                                        with rollup'


it generates partial totals for a list of items using row values, the query works perfect on the terminal.

The issue I'm having is that Cake's query() is overwritting results, I was trying to run a direct query using:

$db =& ConnectionManager::getDataSource('dbc');
$result = mysql_query($sql, $db->_connection );

but _connection() is protected.

Is there a way to override all of Cake's objects and just call mysql_query() / mysql_fetch_assoc() ?


p.s.: this is just for some complex reports I have to build, for the rest I'm using cake's great Model objects :)

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate