• 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?

Jaxel

Well-known member
#1
Code:
$dw = XenForo_DataWriter::create('EWRmedio_DataWriter_Keywords', XenForo_DataWriter::ERROR_SILENT);
$dw->set('keyword_text', $text);
$dw->save();
"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'
 

Mike

XenForo developer
Staff member
#2
It just prevents validation errors, not DB errors. Ideally, you should be doing unique checks via validation.
 

Jaxel

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

Jaxel

Well-known member
#4
It just prevents validation errors, not DB errors. Ideally, you should be doing unique checks via validation.
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.