@@ -25,7 +25,20 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
25
25
{
26
26
parent ::__construct ($ pdo , $ database , $ tablePrefix , $ config );
27
27
28
- $ enableForeignKeyConstraints = $ this ->getForeignKeyConstraintsConfigurationValue ();
28
+ $ this ->configureForeignKeyConstraints ();
29
+ $ this ->configureBusyTimeout ();
30
+ $ this ->configureJournalMode ();
31
+ $ this ->configureSynchronous ();
32
+ }
33
+
34
+ /**
35
+ * Enable or disable foreign key constraints if configured.
36
+ *
37
+ * @return void
38
+ */
39
+ protected function configureForeignKeyConstraints (): void
40
+ {
41
+ $ enableForeignKeyConstraints = $ this ->getConfig ('foreign_key_constraints ' );
29
42
30
43
if ($ enableForeignKeyConstraints === null ) {
31
44
return ;
@@ -44,6 +57,72 @@ public function __construct($pdo, $database = '', $tablePrefix = '', array $conf
44
57
}
45
58
}
46
59
60
+ /**
61
+ * Set the busy timeout if configured.
62
+ *
63
+ * @return void
64
+ */
65
+ protected function configureBusyTimeout (): void
66
+ {
67
+ $ milliseconds = $ this ->getConfig ('busy_timeout ' );
68
+
69
+ if ($ milliseconds === null ) {
70
+ return ;
71
+ }
72
+
73
+ try {
74
+ $ this ->getSchemaBuilder ()->setBusyTimeout ($ milliseconds );
75
+ } catch (QueryException $ e ) {
76
+ if (! $ e ->getPrevious () instanceof SQLiteDatabaseDoesNotExistException) {
77
+ throw $ e ;
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Set the journal mode if configured.
84
+ *
85
+ * @return void
86
+ */
87
+ protected function configureJournalMode (): void
88
+ {
89
+ $ mode = $ this ->getConfig ('journal_mode ' );
90
+
91
+ if ($ mode === null ) {
92
+ return ;
93
+ }
94
+
95
+ try {
96
+ $ this ->getSchemaBuilder ()->setJournalMode ($ mode );
97
+ } catch (QueryException $ e ) {
98
+ if (! $ e ->getPrevious () instanceof SQLiteDatabaseDoesNotExistException) {
99
+ throw $ e ;
100
+ }
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Set the synchronous mode if configured.
106
+ *
107
+ * @return void
108
+ */
109
+ protected function configureSynchronous (): void
110
+ {
111
+ $ mode = $ this ->getConfig ('synchronous ' );
112
+
113
+ if ($ mode === null ) {
114
+ return ;
115
+ }
116
+
117
+ try {
118
+ $ this ->getSchemaBuilder ()->setSynchronous ($ mode );
119
+ } catch (QueryException $ e ) {
120
+ if (! $ e ->getPrevious () instanceof SQLiteDatabaseDoesNotExistException) {
121
+ throw $ e ;
122
+ }
123
+ }
124
+ }
125
+
47
126
/**
48
127
* Escape a binary value for safe SQL embedding.
49
128
*
@@ -128,14 +207,4 @@ protected function getDefaultPostProcessor()
128
207
{
129
208
return new SQLiteProcessor ;
130
209
}
131
-
132
- /**
133
- * Get the database connection foreign key constraints configuration option.
134
- *
135
- * @return bool|null
136
- */
137
- protected function getForeignKeyConstraintsConfigurationValue ()
138
- {
139
- return $ this ->getConfig ('foreign_key_constraints ' );
140
- }
141
210
}
0 commit comments