2
2
/*!
3
3
* Medoo database framework
4
4
* https://medoo.in
5
- * Version 1.4.3
5
+ * Version 1.4.5
6
6
*
7
7
* Copyright 2017, Angel Lai
8
8
* Released under the MIT license
@@ -298,16 +298,23 @@ public function exec($query, $map = [])
298
298
299
299
$ statement = $ this ->pdo ->prepare ($ query );
300
300
301
- foreach ($ map as $ key => $ value )
301
+ if ($ statement )
302
302
{
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
+ }
305
307
306
- $ statement ->execute ();
308
+ $ statement ->execute ();
307
309
308
- $ this ->statement = $ statement ;
310
+ $ this ->statement = $ statement ;
309
311
310
- return $ statement ;
312
+ return $ statement ;
313
+ }
314
+ else
315
+ {
316
+ return false ;
317
+ }
311
318
}
312
319
313
320
protected function generate ($ query , $ map )
@@ -343,7 +350,7 @@ protected function tableQuote($table)
343
350
344
351
protected function mapKey ()
345
352
{
346
- return ':MeDoOmEdOo_ ' . $ this ->guid ++;
353
+ return ':MeDoO_ ' . $ this ->guid ++ . ' _mEdOo ' ;
347
354
}
348
355
349
356
protected function columnQuote ($ string )
@@ -464,6 +471,15 @@ protected function dataImplode($data, &$map, $conjunctor)
464
471
preg_match ('/(#?)([a-zA-Z0-9_\.]+)(\[(?<operator>\>|\>\=|\<|\<\=|\!|\<\>|\>\<|\!?~)\])?/i ' , $ key , $ match );
465
472
$ column = $ this ->columnQuote ($ match [ 2 ]);
466
473
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
+
467
483
if (isset ($ match [ 'operator ' ]))
468
484
{
469
485
$ operator = $ match [ 'operator ' ];
@@ -539,17 +555,15 @@ protected function dataImplode($data, &$map, $conjunctor)
539
555
540
556
foreach ($ value as $ index => $ item )
541
557
{
542
- $ map_key .= 'L ' . $ index ;
543
-
544
558
$ item = strval ($ item );
545
559
546
560
if (!preg_match ('/(\[.+\]|_|%.+|.+%)/ ' , $ item ))
547
561
{
548
562
$ item = '% ' . $ item . '% ' ;
549
563
}
550
564
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 ];
553
567
}
554
568
555
569
$ wheres [] = '( ' . implode ($ connector , $ like_clauses ) . ') ' ;
@@ -564,10 +578,6 @@ protected function dataImplode($data, &$map, $conjunctor)
564
578
$ condition .= $ map_key ;
565
579
$ map [ $ map_key ] = [$ value , PDO ::PARAM_INT ];
566
580
}
567
- elseif (strpos ($ key , '# ' ) === 0 )
568
- {
569
- $ condition .= $ this ->fnQuote ($ key , $ value );
570
- }
571
581
else
572
582
{
573
583
$ condition .= $ map_key ;
@@ -1458,7 +1468,7 @@ public function debug()
1458
1468
1459
1469
public function error ()
1460
1470
{
1461
- return $ this ->statement -> errorInfo ();
1471
+ return $ this ->statement ? $ this -> statement -> errorInfo () : null ;
1462
1472
}
1463
1473
1464
1474
public function last ()
0 commit comments