Commit 8593b705 authored by Alexander Butenko's avatar Alexander Butenko

Merge pull request #396 from avbdr/master

fixes
parents 3c8898c5 f889dbc3
...@@ -1331,7 +1331,9 @@ class MysqliDb ...@@ -1331,7 +1331,9 @@ class MysqliDb
$isInsert = preg_match('/^[INSERT|REPLACE]/', $this->_query); $isInsert = preg_match('/^[INSERT|REPLACE]/', $this->_query);
$dataColumns = array_keys($tableData); $dataColumns = array_keys($tableData);
if ($isInsert) { if ($isInsert) {
$this->_query .= ' (`' . implode($dataColumns, '`, `') . '`) VALUES ('; if (isset ($dataColumns[0]))
$this->_query .= ' (`' . implode($dataColumns, '`, `') . '`) ';
$this->_query .= ' VALUES (';
} else { } else {
$this->_query .= " SET "; $this->_query .= " SET ";
} }
......
...@@ -18,7 +18,7 @@ MysqliDb -- Simple MySQLi wrapper and object mapper with prepared statements ...@@ -18,7 +18,7 @@ MysqliDb -- Simple MySQLi wrapper and object mapper with prepared statements
**[Subqueries](#subqueries)** **[Subqueries](#subqueries)**
**[EXISTS / NOT EXISTS condition](#exists--not-exists-condition)** **[EXISTS / NOT EXISTS condition](#exists--not-exists-condition)**
**[Has method](#has-method)** **[Has method](#has-method)**
**[Helper Functions](#helper-commands)** **[Helper Methods](#helper-methods)**
**[Transaction Helpers](#transaction-helpers)** **[Transaction Helpers](#transaction-helpers)**
### Installation ### Installation
...@@ -582,7 +582,7 @@ if($db->has("users")) { ...@@ -582,7 +582,7 @@ if($db->has("users")) {
return "Wrong user/password"; return "Wrong user/password";
} }
``` ```
### Helper commands ### Helper methods
Reconnect in case mysql connection died: Reconnect in case mysql connection died:
```php ```php
if (!$db->ping()) if (!$db->ping())
...@@ -601,6 +601,12 @@ Check if table exists: ...@@ -601,6 +601,12 @@ Check if table exists:
if ($db->tableExists ('users')) if ($db->tableExists ('users'))
echo "hooray"; echo "hooray";
``` ```
mysqli_real_escape_string() wrapper:
```php
$escaped = $db->escape ("' and 1=1");
```
### Transaction helpers ### Transaction helpers
Please keep in mind that transactions are working on innoDB tables. Please keep in mind that transactions are working on innoDB tables.
Rollback transaction if insert fails: Rollback transaction if insert fails:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment