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

ERROR_SILENT in DataWriter not functioning as expected?

Discussion in 'XenForo Development Discussions' started by Jaxel, Nov 11, 2010.

  1. Jaxel

    Jaxel Well-Known Member

    $dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Keywords', XenForo_DataWriter::ERROR_SILENT);
    $dw->set('keyword_text', $text);
    "keyword_text" is defined as a UNIQUE column... I am trying to write to the table, but I want it to silently fail when it can't write to keyword_text because its not unique. I figured adding ERROR_SILENT would make the datawriter fail silently, like it did in vBulletin. However, it doesn't.

    Mysqli statement execute error : Duplicate entry 'soulcaliburiv' for key 'keyword_text'
  2. Mike

    Mike XenForo Developer Staff Member

    It just prevents validation errors, not DB errors. Ideally, you should be doing unique checks via validation.
  3. Jaxel

    Jaxel Well-Known Member

    I was hoping for a full silent failure option... if a video has 30 keywords, thats 30 additional queries for validation that I was hoping to avoid.
  4. Jaxel

    Jaxel Well-Known Member

    Okay... if I can't fail silently... how would I check for unique COMPOSITE keys...

    I have a table called EWRmedio_keylinks, which has a composite unique of (keyword_id, media_id), it also has a primary key of keylink_id. Basically, a keyword, can't be linked to the same media at the same time; very simple.
  5. Mike

    Mike XenForo Developer Staff Member

    You can do the validation in _preSave. Have a look at the permission DW for an example.
    Chris D likes this.
  6. Jaxel

    Jaxel Well-Known Member

    Why is it all my questions always have the SIMPLEST of solutions? Do I think too much?

    Archimedes would have a field day...

Share This Page