1. 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)

Discussion in 'XenForo Development Discussions' started by Marc, May 27, 2011.

  1. Marc

    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.
     
  2. Marc

    Marc Well-Known Member

    Been tryin to suss out how to do this now for about 2 hours and failing miserably :( ... So close
     
  3. Marc

    Marc Well-Known Member

    Sorted this by adding a check for the records existance before setting and saving items to the writer :)
     
  4. Jeremy P

    Jeremy P Well-Known Member

    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);
    }
     

Share This Page