Skip to content

Commit 8593b70

Browse files
committed
Merge pull request #396 from avbdr/master
fixes
2 parents 3c8898c + f889dbc commit 8593b70

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

MysqliDb.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

readme.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff 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
586586
Reconnect in case mysql connection died:
587587
```php
588588
if (!$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
605611
Please keep in mind that transactions are working on innoDB tables.
606612
Rollback transaction if insert fails:

0 commit comments

Comments
 (0)