DataWriter - Existing Data Required (Help)

Marc

Well-known member
OK I have managed to get my datawriter updating data within the database when it exists as I was trying to do previously, however now when there is no data already existing I get:

"The existing data required by the datawriter could not be found"

I've been looking at this for a while now and I know I need to check it first, but no matter what I try it doesnt work.

PHP:
protected function _getUpdateCondition($tableName)
{
return 'member_id = ' . $this->_db->quote($this->getExisting('member_id'));
        }

I need it to either update the table if it exists already, or add a new entry if it doesnt. At the moment if it already exist then it works fine.
 
Been tryin to suss out how to do this now for about 2 hours and failing miserably :( ... So close
 
Sorted this by adding a check for the records existance before setting and saving items to the writer :)
 
You should have something like this (of course adapted for your specific addon) in your data writer..
PHP:
protected function _getExistingData($data)
{
if (!$albumId = $this->_getExistingPrimaryKey($data))
{
return false;
}

if (!$album = $this->_getAlbumModel()->getAlbumById($albumId))
{
return false;
}

return $this->getTablesDataFromArray($album);
}
 
Top Bottom