Have run this query in phpMyAdmin and it works fine:
SELECT COUNT( * ) AS `Rows` , diallednumber
FROM logData
GROUP BY diallednumber
ORDER BY `Rows` DESC
LIMIT 20
And am trying to put it into a XPDO query as follows
//Query to find most common dialled numbers
$c = $modx->myDB->newQuery('LogData');
$c->select('COUNT( * ) AS `Rows` , diallednumber');
$c->groupby('diallednumber');
$c->sortby('Rows', 'DESC');
$c->limit(1);
//Total found results
$total = $modx->myDB->getCount('LogData', $c);
echo '<p>Total records found: ' . $total . '</p>';
//Run query
$results = $modx->myDB->getCollection('LogData', $c);
If I run this I will get:
Total records found: 0
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /home/sites/paradoxal.co.uk/public_html/nhs/core/xpdo/om/xpdoobject.class.php on line 1686
If I take out
$results = $modx->myDB->getCollection('LogData', $c);
The errors goes away. Any ideas what I am doing wrong?
Thanks in advance.