@@ -103,8 +103,8 @@ protected function raw_query(string $sql, string $index = null, bool $assoc = nu
103
103
104
104
if (is_bool ($ result )){
105
105
106
- if (!$ result ){
107
- throw new DriverException ($ this ->db ->error );
106
+ if ($ this -> db -> errno !== 0 || !$ result ){
107
+ throw new DriverException ($ this ->db ->error , $ this -> db -> errno );
108
108
}
109
109
110
110
return $ result ; // @codeCoverageIgnore
@@ -122,6 +122,7 @@ protected function prepared_query(string $sql, array $values = null, string $ind
122
122
$ assoc = $ assoc ?? true ;
123
123
$ stmt = $ this ->db ->stmt_init ();
124
124
$ stmt ->prepare ($ sql );
125
+ $ this ->stmtError ($ this ->db ->errno , $ this ->db ->error );
125
126
126
127
if (count ($ values ) > 0 ){
127
128
call_user_func_array ([$ stmt , 'bind_param ' ], $ this ->getReferences ($ values ));
@@ -177,6 +178,7 @@ protected function prepared_query(string $sql, array $values = null, string $ind
177
178
protected function multi_query (string $ sql , array $ values ){
178
179
$ stmt = $ this ->db ->stmt_init ();
179
180
$ stmt ->prepare ($ sql );
181
+ $ this ->stmtError ($ this ->db ->errno , $ this ->db ->error );
180
182
181
183
foreach ($ values as $ row ){
182
184
call_user_func_array ([$ stmt , 'bind_param ' ], $ this ->getReferences ($ row ));
@@ -193,6 +195,7 @@ protected function multi_query(string $sql, array $values){
193
195
protected function multi_callback_query (string $ sql , iterable $ data , $ callback ){
194
196
$ stmt = $ this ->db ->stmt_init ();
195
197
$ stmt ->prepare ($ sql );
198
+ $ this ->stmtError ($ this ->db ->errno , $ this ->db ->error );
196
199
197
200
foreach ($ data as $ k => $ row ){
198
201
$ row = call_user_func_array ($ callback , [$ row , $ k ]);
@@ -209,6 +212,20 @@ protected function multi_callback_query(string $sql, iterable $data, $callback){
209
212
return true ;
210
213
}
211
214
215
+ /**
216
+ * @param int $errno
217
+ * @param string $errstr
218
+ *
219
+ * @throws \chillerlan\Database\Drivers\DriverException
220
+ */
221
+ protected function stmtError (int $ errno , string $ errstr ):void {
222
+
223
+ if ($ errno !== 0 ){
224
+ throw new DriverException ($ errstr , $ errno );
225
+ }
226
+
227
+ }
228
+
212
229
/**
213
230
* Copies an array to an array of referenced values
214
231
*
0 commit comments