@@ -85,7 +85,7 @@ public function delete(string $table, array $where): \PDOStatement
85
85
86
86
public function formatFields (array $ fields , string $ table = '' , string $ prefix = '' ): string
87
87
{
88
- if (! $ fields ) {
88
+ if ($ fields === [] ) {
89
89
throw new \InvalidArgumentException ('No fields provided for the query ' );
90
90
}
91
91
@@ -130,7 +130,7 @@ public function formatTable(string $table, string $alias = ''): string
130
130
*/
131
131
private function formatConditions (array $ conditions , array & $ parameters ): string
132
132
{
133
- if (! $ conditions ) {
133
+ if ($ conditions === [] ) {
134
134
throw new \InvalidArgumentException ('No conditions provided for the query ' );
135
135
}
136
136
@@ -160,7 +160,7 @@ private function formatClause(string $field, $value, array & $parameters): strin
160
160
return $ value !== null ;
161
161
});
162
162
163
- if ($ value ) {
163
+ if ($ value !== [] ) {
164
164
$ placeholders = $ this ->formatParameters ($ value , $ parameters );
165
165
return "( $ escaped IN $ placeholders OR $ escaped IS NULL) " ;
166
166
}
@@ -250,7 +250,7 @@ private function formatLimit(?int $limit, array & $parameters): string
250
250
*/
251
251
private function formatAssignments (array $ values , array & $ parameters ): string
252
252
{
253
- if (! $ values ) {
253
+ if ($ values === [] ) {
254
254
throw new \InvalidArgumentException ('No values provided for the query ' );
255
255
}
256
256
@@ -298,6 +298,10 @@ public function query(string $sql, array $parameters = []): \PDOStatement
298
298
{
299
299
$ query = $ this ->getConnection ()->prepare ($ sql );
300
300
301
+ if (! $ query instanceof \PDOStatement) {
302
+ throw new \UnexpectedValueException ('Unexpected value returned by prepare query ' );
303
+ }
304
+
301
305
foreach ($ parameters as $ name => $ value ) {
302
306
$ this ->bindQueryParameter ($ query , \is_int ($ name ) ? $ name + 1 : $ name , $ value );
303
307
}
0 commit comments