What version are you using? I just did a quick test using my
playground database, and this:
$this->set('test', $this->Tag->find('count', array('conditions' =>
array('2=2','3=3'),
'recursive' => 0, 'fields' => array('(COUNT(DISTINCT Tag.parent_id))
AS
count'))));
Generated this SQL:
SELECT (COUNT(DISTINCT Tag.parent_id)) AS count FROM `tags` AS `Tag`
LEFT JOIN `tags` AS `ParentTag` ON (`Tag`.`parent_id` =
`ParentTag`.`id`) WHERE 2=2 AND 3=3
As expected, which worked perfectly (rev. 6416).
On Feb 11, 11:17 am, Nasko <[EMAIL PROTECTED]> wrote:
> grigri,
>
> I tried this an got this SQL query:
>
> SELECT Array, 1, COUNT(DISTINCT User.id) AS count, `User`.,
> `User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS `Group` ON
> (`User`.`group_id` = `Group`.`id`) LEFT JOIN `genders` AS `Gender` ON
> (`User`.`gender_id` = `Gender`.`id`) LEFT JOIN `countries` AS
> `Country` ON (`User`.`country_id` = `Country`.`id`) LEFT JOIN
> `gender_prefferences_users` AS `GenderPrefferenceUser` ON
> (`GenderPrefferenceUser`.`user_id` = `User`.`id`) WHERE count LIMIT 1
>
> 1064: You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near ' `User`.`id` FROM `users` AS `User` LEFT JOIN `groups` AS
> `Group` ON (`User`.`gr' at line 1
>
> In addition the following notices were thrown:
>
> Notice (8): Undefined offset: 0 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1424]
> Notice (8): Undefined offset: 0 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 0 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 0 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 0 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Undefined offset: 1 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 1 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 1 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 1 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Undefined offset: 2 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 2 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 2 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 2 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Undefined offset: 3 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 3 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 3 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 3 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Undefined offset: 4 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 4 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 4 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 4 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Undefined offset: 5 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1426]
> Notice (8): Undefined offset: 5 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1429]
> Notice (8): Undefined offset: 5 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1433]
> Notice (8): Undefined offset: 5 [CORE\cake\libs\model\datasources
> \dbo_source.php, line 1436]
> Notice (8): Array to string conversion [CORE\cake\libs\model
> \datasources\dbo_source.php, line 1186]
>
> On 11 Фев, 12:33, grigri <[EMAIL PROTECTED]> wrote:
>
> > try implementing User::paginateCount and changing the query:
>
> > class User extends AppModel {
> > function paginateCount($conditions, $recursive) {
> > return $this->find('count', array('conditions' => $conditions,
> > 'recursive' => $recursive, 'fields' => 'COUNT(DISTINCT User.id) AS
> > count'));
> > }
>
> > }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" 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
-~----------~----~----~----~------~----~------~--~---