问题
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