@@ -242,12 +242,12 @@ protected function openConnection($create_tables = false): void
242242
243243 $ this ->PDO ->exec ('PRAGMA journal_mode = OFF ' );
244244
245- $ this ->PDO ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_WARNING );
245+ $ this ->PDO ->setAttribute (PDO ::ATTR_ERRMODE , PDO ::ERRMODE_EXCEPTION );
246246 $ this ->PDO ->setAttribute (PDO ::ATTR_TIMEOUT , 100 );
247247
248248 if ($ create_tables == true ) {
249249 // Create url-table (if not exists)
250- $ this ->PDO ->exec ('CREATE TABLE IF NOT EXISTS urls (id integer PRIMARY KEY AUTOINCREMENT,
250+ $ created = $ this ->PDO ->exec ('CREATE TABLE IF NOT EXISTS urls (id integer PRIMARY KEY AUTOINCREMENT,
251251 in_process bool DEFAULT 0,
252252 processed bool DEFAULT 0,
253253 priority_level integer,
@@ -277,18 +277,19 @@ protected function openConnection($create_tables = false): void
277277 */
278278 protected function createPreparedInsertStatement (): void
279279 {
280- if (isset ($ this ->PreparedInsertStatement ) && $ this ->PreparedInsertStatement == null ) {
281- // Prepared statement for URL-inserts
282- $ this ->PreparedInsertStatement = $ this ->PDO ->prepare ('INSERT OR IGNORE INTO urls (priority_level, distinct_hash, link_raw, linkcode, linktext, refering_url, url_rebuild, is_redirect_url, url_link_depth)
283- VALUES(:priority_level,
284- :distinct_hash,
285- :link_raw,
286- :linkcode,
287- :linktext,
288- :refering_url,
289- :url_rebuild,
290- :is_redirect_url,
291- :url_link_depth); ' );
280+ if (!isset ($ this ->PreparedInsertStatement ) || $ this ->PreparedInsertStatement == null ) {
281+ $ this ->PreparedInsertStatement = $ this ->PDO ->prepare (
282+ 'INSERT OR IGNORE INTO urls (priority_level, distinct_hash, link_raw, linkcode, linktext, refering_url, url_rebuild, is_redirect_url, url_link_depth)
283+ VALUES(:priority_level,
284+ :distinct_hash,
285+ :link_raw,
286+ :linkcode,
287+ :linktext,
288+ :refering_url,
289+ :url_rebuild,
290+ :is_redirect_url,
291+ :url_link_depth); '
292+ );
292293 }
293294 }
294295
0 commit comments