0

I write below code in beforeFilter in aap_controller.

$this->query('delete * from suggest_debate_tags where suggest_debate_id = 0');

Error:

Call to undefined method UsersController::query()

2 Answers 2

1

The AppController class extends Controller class which is the base for Controllers. query is a part of the model so $this->query() will not work. You need to put the query() call in a model and call the model from your AppController.

Sign up to request clarification or add additional context in comments.

Comments

0

Finally i got solution

I write below code in beforeFilter in aap_controller.

App::import('Model','SuggestDebateTag');

$cnt_tag_arr = $this->SuggestDebateTag->find('count',array ( "SuggestDebateTag.suggest_debate_id" => 0));

if($cnt_tag_arr > 0)
{

        $conditions = array ( "SuggestDebateTag.suggest_debate_id" => 0);
        $this->SuggestDebateTag->deleteAll($conditions);

}

And I write below code in users_controller.php

var $uses = array('SuggestDebateTag');

Its work fine.

1 Comment

What you're essentially doing is that you're clearing the suggest_debat_tags table every time a request comes in. Are you sure you want to do that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.