Cakephp Сохраняют с таблицей, где первичный ключ не является 'идентификатором'

Вот то, как сделать это на командной строке:

for file in `find . -name configure`; do
  svn ps svn:executable yes ${file}
done

Или всего для одного файла (configure имя файла здесь):

svn ps svn:executable yes configure
5
задан gevorg 13 June 2016 в 12:11
поделиться

2 ответа

You should manually override the primary key field in the model (which is the right place to do this - the name of a primary key field is an attribute of the model, and not something that should be 'fudged' around in the controller.)

class Example extends AppModel {    var $primaryKey = 'example_id'; // example_id is the field name in the database}

The above code is from http://book.cakephp.org/view/437/primaryKey

While the suggestion to turn off validation will work, it's not the right way to go about it.

Lastly, if you're setting model variables within a controller, you use $this->Model->set('attributeName',value) rather than $this->Model->attributeName

15
ответ дан 18 December 2019 в 13:15
поделиться

Похоже, контроллер истории проверял данные, и данные были недопустимыми. Добавление следующей строки в контроллер остановит проверку данных.

$this->Story->validate = array(); // Stop valadation on the story.

Я нашел решение на этой странице 15 основных советов по CakePHP

-1
ответ дан 18 December 2019 в 13:15
поделиться
Другие вопросы по тегам:

Похожие вопросы: