Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
catfan committed May 22, 2017
2 parents 1134cd6 + 865854b commit 00b2804
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/Medoo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*!
* Medoo database framework
* https://medoo.in
* Version 1.4.2
* Version 1.4.3
*
* Copyright 2017, Angel Lai
* Released under the MIT license
Expand All @@ -20,6 +20,8 @@ class Medoo

protected $prefix;

protected $statement;

protected $option = [];

protected $logs = [];
Expand Down Expand Up @@ -303,6 +305,8 @@ public function exec($query, $map = [])

$statement->execute();

$this->statement = $statement;

return $statement;
}

Expand Down Expand Up @@ -1091,6 +1095,12 @@ public function insert($table, $datas)

foreach ($columns as $key)
{
if (strpos($key, '#') === 0)
{
$values[] = $this->fnQuote($key, $data[ $key ]);
continue;
}

$map_key =$this->mapKey();

$values[] = $map_key;
Expand Down Expand Up @@ -1160,6 +1170,14 @@ public function update($table, $data, $where = null)

foreach ($data as $key => $value)
{
$column = $this->columnQuote(preg_replace("/(^#|\s*\[(JSON|\+|\-|\*|\/)\]$)/i", '', $key));

if (strpos($key, '#') === 0)
{
$fields[] = $column . ' = ' . $value;
continue;
}

$map_key = $this->mapKey();

preg_match('/(?<column>[a-zA-Z0-9_]+)(\[(?<operator>\+|\-|\*|\/)\])?/i', $key, $match);
Expand All @@ -1168,12 +1186,11 @@ public function update($table, $data, $where = null)
{
if (is_numeric($value))
{
$fields[] = $this->columnQuote($match[ 'column' ]) . ' = ' . $this->columnQuote($match[ 'column' ]) . ' ' . $match[ 'operator' ] . ' ' . $value;
$fields[] = $column . ' = ' . $column . ' ' . $match[ 'operator' ] . ' ' . $value;
}
}
else
{
$column = $this->columnQuote(preg_replace("/(^#|\s*\[JSON\]$)/i", '', $key));
$fields[] = $column . ' = ' . $map_key;

switch (gettype($value))
Expand Down Expand Up @@ -1441,7 +1458,7 @@ public function debug()

public function error()
{
return $this->pdo->errorInfo();
return $this->statement->errorInfo();
}

public function last()
Expand Down

0 comments on commit 00b2804

Please sign in to comment.