4

my cakephp app throws me that error,on that line:

class List extends AppModel {

and i cannot understand why.

the whole List.php model file is:

<?php

App::uses('AuthComponent', 'Controller/Component');
class List extends AppModel {

public function beforeSave($options = array()) {
    if (isset($this->data[$this->alias]['password'])) {
        $this->data[$this->alias]['password'] = AuthComponent::password($this->data[$this->alias]['password']);
    }
    return true;
}
?>

Does anybody has an idea why this is happening?

thank you!

1 Answer 1

14

List is a reserved keyword in PHP

You're getting this error, because list is a reserved keyword in PHP and therefore cannot be used as the name of your class;

http://php.net/manual/en/reserved.keywords.php

Rename your model to something else and you should be fine. To still use the same database-table, manually specify the database-table that the model uses via the useTable property;

class MyList extends AppModel
{
    public $useTable = 'lists';
}
Sign up to request clarification or add additional context in comments.

1 Comment

It's easily overlooked :) Glad I could help

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.