Hi,

The following should do the job:

[..]
// for the controller
$params['fields'] = array(
    'DATE_FORMAT(created, '%d.%m.%Y') AS sdate',
    'COUNT(savedtime) AS saved',
    'COUNT(encashedtime) AS encashed');
$params['conditions'] = array(
    'voucher_id' => array(8, 124, 120),
    'created <= NOW()',
    'DATE_SUB(NOW(), INTERVAL 30 DAY)'
);
$params['order'] = 'sdate';
$params['group'] = 'sdate';
$res = $this->UsersBook->find('all', $params);
[..]

Hope that helps,
harpax


On 24 Apr., 16:28, voocake <[email protected]> wrote:
> Hello,
>
> I have nice SQL query which makes most of the work for me, but i have
> no plan how to convert it to a cakephp conform condition array. I'm
> aware of the possibility to make a custom query, but i'm trying to
> avoid this.
>
> May someone can help me with this?
>
> Here is the statement:
>
> SELECT DATE_FORMAT(created, '%d.%m.%Y') AS sdate, COUNT(savedtime) AS
> saved , COUNT(encashedtime) AS encashed FROM users_books WHERE
> voucher_id IN (8, 124, 120)
> AND created <= NOW()
> AND DATE_SUB(NOW(), INTERVAL 30 DAY)
> GROUP BY sdate
> ORDER BY sdate
>
> Thx
> voocake

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to