简体   繁体   中英

cakePHP - SQL Query: parseCriteria

I follow all steps described in: https://github.com/CakeDC/search/blob/master/Docs/Tutorials/Quick-Start.md but my search form dont work.

I'm received that message on load index page:

Error: SQLSTATE[42000]: Syntax error or access violation: 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 'parseCriteria' at line 1

SQL Query: parseCriteria

I searched several places, but found nothing that would help solve this.

class UsersController extends AppController {

    public $components = array(
        'Search.Prg'
    );

    public function index() {
        $this->Prg->commonProcess();
        $this->Paginator->settings['conditions'] = $this->User->parseCriteria($this->Prg->parsedParams());
        $this->set('users', $this->Paginator->paginate());
    }
}

class User extends AppModel {

    public $actsAs = array(
        'Search.Searchable'
    );

    public $filterArgs = array(
        'username' => array(
            'type' => 'like',
            'field' => 'username'
        ),
        'email' => array(
            'type' => 'like',
            'field' => 'email'
        ),
        'active' => array(
            'type' => 'value'
        )
    );

}

<!--index.ctp-->
    echo $this->Form->create();
    echo $this->Form->input('username');
    echo $this->Form->input('email');
    echo $this->Form->input('active', array(
        'type' => 'checkox'
    ));
    echo $this->Form->submit(__('Submit'));
    echo $this->Form->end();

I had this same problem. In the end I realized that in the controllers where the problem exists, I don't have correspondent models. So, most likely, the error lies in the model, not in the controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM