• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

DataWriter - Existing Data Required (Help)

Marc

Well-known member
#1
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.
 

Jeremy P

Well-known member
#4
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);
}