@@ -232,6 +232,13 @@ class WP_SQLite_Driver {
232232 */
233233 private $ pdo ;
234234
235+ /**
236+ * Enables debug mode.
237+ *
238+ * @var bool
239+ */
240+ private $ debug ;
241+
235242 /**
236243 * Last executed MySQL query.
237244 *
@@ -323,6 +330,7 @@ class WP_SQLite_Driver {
323330 * Must be set when PDO instance is not provided.
324331 * @type PDO|null $connection Optional. PDO instance with SQLite connection.
325332 * If not provided, a new PDO instance will be created.
333+ * @type bool $debug Optional. Enable debug mode.
326334 * @type int|null $timeout Optional. SQLite timeout in seconds.
327335 * The time to wait for a writable lock.
328336 * @type string|null $sqlite_journal_mode Optional. SQLite journal mode.
@@ -340,6 +348,9 @@ public function __construct( array $options ) {
340348 $ this ->pdo = $ options ['connection ' ];
341349 }
342350
351+ // Debug mode.
352+ $ this ->debug = isset ( $ options ['debug ' ] ) && true === $ options ['debug ' ];
353+
343354 // Create a PDO connection if it is not provided.
344355 if ( ! $ this ->pdo ) {
345356 if ( ! isset ( $ options ['path ' ] ) || ! is_string ( $ options ['path ' ] ) ) {
@@ -542,7 +553,7 @@ public function query( string $query, $fetch_mode = PDO::FETCH_OBJ, ...$fetch_mo
542553 } catch ( Throwable $ rollback_exception ) {
543554 // Ignore rollback errors.
544555 }
545- if ( defined ( ' PDO_DEBUG ' ) && PDO_DEBUG === true ) {
556+ if ( true === $ this -> debug ) {
546557 throw $ e ;
547558 }
548559 return $ this ->handle_error ( $ e );
0 commit comments