find I do on this model.
Ad I wanted to add the check IN the afterFind method not before or
after, but it looks like this is not possible. Well I add it to the
controller methods where necessary, I just hope I could budle them at
one place.
Anja (aka acl68)
Am 22.08.2011 17:26, schrieb Thomas Ploch:
> Well, the default findQueryType for Controller::paginate() is 'all'.
> Unless you set a different type in the paginate options array, you
> should get 'all' as the findQueryType. If you want to set a different
> findType to paginate, use:
>
> $this->paginate[0] = 'yourCustomFindType'; // or
> $this->paginate['ModelAlias'][0] = 'yourCustomFindType';
>
> Regards,
> Thomas
>
>
> Am 22.08.2011 17:03, schrieb Anja Liebermann:
>> I use the pagination, but there is quite a weird condition in the query:
>>
>> Here is the query going to the database:
>>
>> SELECT `Article`.`id`, `Article`.`author_id`, `Article`.`cat_id`,
>> `Article`.`last_comment_id`, `Article`.`title`, `Article`.`teaser`,
>> `Article`.`created`, `Article`.`published`,
>> `Article`.`numeric_visibility`, `Article`.`like_count`,
>> `Article`.`comments_count`, `Article`.`visitations_count`,
>> `Article`.`hidden`, `Article`.`flag_top`, `LastComment`.`user_id`,
>> `LastComment`.`created`
>> FROM `articles` AS `Article`
>> LEFT JOIN `users` AS `ArticleAuthor` ON (`Article`.`author_id` =
>> `ArticleAuthor`.`id`)
>> LEFT JOIN `comments` AS `LastComment` ON (`Article`.`last_comment_id`
>> = `LastComment`.`id`)
>> WHERE
>> `Article`.`numeric_visibility` >= 3
>> AND MATCH(`Article`.`title`, `Article`.`teaser`, `Article`.`body`,
>> `Article`.`denormalized_tags`) AGAINST('"ocean"' IN BOOLEAN MODE)
>> AND `Article`.`hidden` = 0
>> AND `Article`.`deleted` = 0
>> AND `Article`.`published` > 0
>> ORDER BY `Article`.`updated` DESC LIMIT 8
>>
>> The part with the "match" is added in a special method
>> $cond = $this->_getSearchConditions($search);
>> $cond is an array, to which other conditions are added before it goes
>> via beforeFind and afterFind to the view as a paginated result.
>>
>> Anja
>>
>> Am 22.08.2011 16:45, schrieb Thomas Ploch:
>>> Woops, actually Model::findQueryType is __not__ reset before afterFind()
>>> is triggered. You should normally be able to check for
>>> Model::findQueryType in the afterFind() Callback.
>>>
>>> Are you using custom find types?
>>>
>>> Regards,
>>> Thomas
>>>
>>> Am 22.08.2011 16:33, schrieb Anja Liebermann:
>>>> did that. It is always NULL :(
>>>>
>>>> Anja
>>>>
>>>> Am 22.08.2011 16:25, schrieb Thomas Ploch:
>>>>> Look at Model::findQueryType :-)
>>>>>
>>>>> Am 22.08.2011 15:56, schrieb Anja Liebermann:
>>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> is there a possibility to know which query type ( first, all, count
>>>>>> etc...) was used, when I call afterFind()?
>>>>>>
>>>>>> Depending on the query Type I would like to make different checks.
>>>>>>
>>>>>> If it is not possible, then I have to do it in the controller in
>>>>>> several actions.
>>>>>>
>>>>>>
>>>>>> As always: Thanks in advance for any hints!
>>>>>>
>>>>>> Anja
>>>>>>
>>>>>
>>>>
>>>
>>
>
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment