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 ()
0 commit comments