CakePHP error: Call to a member function getColumnType()

五迷三道 提交于 2019-12-25 05:35:10

问题


I'm trying to edit a record in the database, but the script gives me the following error:

Fatal error: Call to a member function getColumnType() on a non-object in G:\wamp\www\a11\a\cake\libs\model\model.php on line 980

The strange thing is, if I remove id from the form (so it creates a new record) it doesn't complain. That means that there's something wrong with the id column.

But what?

Just before the save I dump the array that is going to be saved:

Array
(
[Process] => Array
    (
        [id] => 5
        [oobject] => 1
        [oproperty] => Number
        [wproperty] => Payed
        [do] => somecode
        [active] => 1
        [name] => Testing
        [changed_user_id] => 3
        [selftrigger] => 1
    )

)

The saving code now looks like this:

$d = $this->data;
if ($this->Process->save($d)) {

id exists in the database

I appreciate any help!


回答1:


The id column is labeled "id" (without quotes), correct? If you are using MySQL, make sure that ID type is int (not any variation) and that it is the primary key with auto-increment. These settings are needed for the model class to function properly.

From this error, it looks like you have set the id column to something other than int.



来源:https://stackoverflow.com/questions/6723635/cakephp-error-call-to-a-member-function-getcolumntype

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!