<?php
namespace wcf\data;
+use wcf\system\database\exception\DatabaseQueryExecutionException;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\WCF;
return $affectedCount;
}
+
+ /**
+ * Creates a new object, returns null if the row already exists.
+ *
+ * @param array $parameters
+ * @return IStorableObject|null
+ * @since 5.3
+ */
+ public static function createOrIgnore(array $parameters = []) {
+ try {
+ return static::create($parameters);
+ }
+ catch (DatabaseQueryExecutionException $e) {
+ // Error code 23000 = duplicate key
+ if ($e->getCode() == '23000') {
+ return null;
+ }
+
+ throw $e;
+ }
+ }
}