I am using this query in raw sql and it returns correct result:
<?php
$query = "SELECT
FROM_UNIXTIME(timestamp,'%b %d %Y') as day,
(
SELECT COUNT(id)*10
FROM screenshots a1
WHERE user_id=24
AND day = FROM_UNIXTIME(timestamp,'%b %d %Y')
) as Stefan
FROM screenshots b
WHERE b.timestamp BETWEEN (UNIX_TIMESTAMP()-604800) AND UNIX_TIMESTAMP()
GROUP BY day";
However when I try to translate it to PHQL it returns: Column 'day' doesn't belong to any of the selected models (1), when preparing. Final PHQL looks something like this:
<?php
$final_query=$this->modelsManager->createQuery("SELECT FROM_UNIXTIME(timestamp,'%b %d %Y') as day, ( SELECT COUNT(id)*10 FROM Screenshots a1 WHERE user_id=24 AND day = FROM_UNIXTIME(timestamp,'%b %d %Y') ) as Stefan FROM Screenshots b WHERE b.timestamp BETWEEN (UNIX_TIMESTAMP()-604800) AND UNIX_TIMESTAMP() GROUP BY day");
Sure I can do raw query, but why it should be like this?