So I have defined a model like this:
class Model extends Zend_Db_Table_Abstract
{
$_primary = 'modelID';
/**
*
* @param mixed $primaryKey
* @return int
*/
public function delete($primaryKey)
{
$where = $this->getAdapter()->quoteInto($this->_primary.' = ?', $primaryKey);
return parent::delete($where);
}
}
When calling the delete method, I get a warning telling me $this->_primary is an array. Why? I have assigned a string value to $_primary property.
From logs:
2012-02-05T17:41:03+00:00 INFO (6): Array
(
[1] => modelID
)
Zend_Db_Table stores primary keys as an array in case a compound key is used, so strictly speaking, it is best (not compulsory) to declare them like this:-
From the docblock in Zend_Db_Table_Abstract:-
And from the dockblock for $_identity:-
So you could probably use that instead.
If you have only one column in your primary key then it will be at $_primary[1].
I think this would work for you:-