Skip to content

Commit 5f7822a

Browse files
author
hooray
committed
更新medoo
1 parent 03bf29d commit 5f7822a

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

inc/medoo.php

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*!
33
* Medoo database framework
44
* https://medoo.in
5-
* Version 1.4.3
5+
* Version 1.4.5
66
*
77
* Copyright 2017, Angel Lai
88
* Released under the MIT license
@@ -298,16 +298,23 @@ public function exec($query, $map = [])
298298

299299
$statement = $this->pdo->prepare($query);
300300

301-
foreach ($map as $key => $value)
301+
if ($statement)
302302
{
303-
$statement->bindValue($key, $value[ 0 ], $value[ 1 ]);
304-
}
303+
foreach ($map as $key => $value)
304+
{
305+
$statement->bindValue($key, $value[ 0 ], $value[ 1 ]);
306+
}
305307

306-
$statement->execute();
308+
$statement->execute();
307309

308-
$this->statement = $statement;
310+
$this->statement = $statement;
309311

310-
return $statement;
312+
return $statement;
313+
}
314+
else
315+
{
316+
return false;
317+
}
311318
}
312319

313320
protected function generate($query, $map)
@@ -343,7 +350,7 @@ protected function tableQuote($table)
343350

344351
protected function mapKey()
345352
{
346-
return ':MeDoOmEdOo_' . $this->guid++;
353+
return ':MeDoO_' . $this->guid++ . '_mEdOo';
347354
}
348355

349356
protected function columnQuote($string)
@@ -464,6 +471,15 @@ protected function dataImplode($data, &$map, $conjunctor)
464471
preg_match('/(#?)([a-zA-Z0-9_\.]+)(\[(?<operator>\>|\>\=|\<|\<\=|\!|\<\>|\>\<|\!?~)\])?/i', $key, $match);
465472
$column = $this->columnQuote($match[ 2 ]);
466473

474+
if (!empty($match[ 1 ]))
475+
{
476+
$wheres[] = $column .
477+
(isset($match[ 'operator' ]) ? ' ' . $match[ 'operator' ] . ' ' : ' = ') .
478+
$this->fnQuote($key, $value);
479+
480+
continue;
481+
}
482+
467483
if (isset($match[ 'operator' ]))
468484
{
469485
$operator = $match[ 'operator' ];
@@ -539,17 +555,15 @@ protected function dataImplode($data, &$map, $conjunctor)
539555

540556
foreach ($value as $index => $item)
541557
{
542-
$map_key .= 'L' . $index;
543-
544558
$item = strval($item);
545559

546560
if (!preg_match('/(\[.+\]|_|%.+|.+%)/', $item))
547561
{
548562
$item = '%' . $item . '%';
549563
}
550564

551-
$like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $map_key;
552-
$map[ $map_key ] = [$item, PDO::PARAM_STR];
565+
$like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $map_key . 'L' . $index;
566+
$map[ $map_key . 'L' . $index ] = [$item, PDO::PARAM_STR];
553567
}
554568

555569
$wheres[] = '(' . implode($connector, $like_clauses) . ')';
@@ -564,10 +578,6 @@ protected function dataImplode($data, &$map, $conjunctor)
564578
$condition .= $map_key;
565579
$map[ $map_key ] = [$value, PDO::PARAM_INT];
566580
}
567-
elseif (strpos($key, '#') === 0)
568-
{
569-
$condition .= $this->fnQuote($key, $value);
570-
}
571581
else
572582
{
573583
$condition .= $map_key;
@@ -1458,7 +1468,7 @@ public function debug()
14581468

14591469
public function error()
14601470
{
1461-
return $this->statement->errorInfo();
1471+
return $this->statement ? $this->statement->errorInfo() : null;
14621472
}
14631473

14641474
public function last()

static/js/hros.popupMenu.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ HROS.popupMenu = (function(){
3838
** 计算右键菜单位置
3939
*/
4040
calcPosition: function(e, obj){
41-
var l = ($(window).width() - e.clientX) < obj.width() ? (e.clientX - obj.width()): e.clientX;
42-
var t = ($(window).height() - e.clientY) < obj.height() ? (e.clientY - obj.height()): e.clientY;
41+
var l = ($(window).width() - e.clientX) < obj.width() ? (e.clientX - obj.width()) : e.clientX;
42+
var t = ($(window).height() - e.clientY) < obj.height() ? (e.clientY - obj.height()) : e.clientY;
4343
obj.css({
4444
left: l,
4545
top: t

static/template/window.art

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</div>
3939
<div class="set-bar">
4040
<div class="fr">
41-
<a class="btn refresh" btn="refresh">
41+
<a class="btn" btn="refresh">
4242
<i class="fa fa-refresh"></i>
4343
<span class="btn-con">刷新</span>
4444
</a>

0 commit comments

Comments
 (0)