File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1331,7 +1331,9 @@ protected function _buildInsertQuery($tableData)
13311331 $ isInsert = preg_match ('/^[INSERT|REPLACE]/ ' , $ this ->_query );
13321332 $ dataColumns = array_keys ($ tableData );
13331333 if ($ isInsert ) {
1334- $ this ->_query .= ' (` ' . implode ($ dataColumns , '`, ` ' ) . '`) VALUES ( ' ;
1334+ if (isset ($ dataColumns [0 ]))
1335+ $ this ->_query .= ' (` ' . implode ($ dataColumns , '`, ` ' ) . '`) ' ;
1336+ $ this ->_query .= ' VALUES ( ' ;
13351337 } else {
13361338 $ this ->_query .= " SET " ;
13371339 }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ MysqliDb -- Simple MySQLi wrapper and object mapper with prepared statements
1818** [ Subqueries] ( #subqueries ) **
1919** [ EXISTS / NOT EXISTS condition] ( #exists--not-exists-condition ) **
2020** [ Has method] ( #has-method ) **
21- ** [ Helper Functions ] ( #helper-commands ) **
21+ ** [ Helper Methods ] ( #helper-methods ) **
2222** [ Transaction Helpers] ( #transaction-helpers ) **
2323
2424### Installation
@@ -582,7 +582,7 @@ if($db->has("users")) {
582582 return "Wrong user/password";
583583}
584584```
585- ### Helper commands
585+ ### Helper methods
586586Reconnect in case mysql connection died:
587587``` php
588588if (!$db->ping())
@@ -601,6 +601,12 @@ Check if table exists:
601601 if ($db->tableExists ('users'))
602602 echo "hooray";
603603```
604+
605+ mysqli_real_escape_string() wrapper:
606+ ``` php
607+ $escaped = $db->escape ("' and 1=1");
608+ ```
609+
604610### Transaction helpers
605611Please keep in mind that transactions are working on innoDB tables.
606612Rollback transaction if insert fails:
You can’t perform that action at this time.
0 commit comments