ZF/PHP
This is my class Votes:
class Votes extends Zend_Db_table {
protected $_name = 'votes';
public function vote($object_id, $user_id, $vote){
$data = array('object_id' => $object_id, 'user_id' => $user_id, 'value' => $vote);
$this->insert($data);
return true;
}
}
The ‘votes’ has ‘id’ primary key.
I get:
Integrity constraint violation: 1062 Duplicate entry ‘0’ for key ‘PRIMARY’
when i call vote. Which means the engine every time try to make an insert with ‘0’ as id’s value.
How to force insert to automatically increment ‘id’ column?
Make the Vote table id, an auto increment field. This should solve the problem.