@@ -680,7 +680,7 @@ protected function _wh($qb_key, $key, $value = NULL, $type = 'AND ', $escape = N
680680 {
681681 if ($ escape === TRUE )
682682 {
683- $ v = ' ' . $ this ->escape ($ v );
683+ $ v = $ this ->escape ($ v );
684684 }
685685
686686 if ( ! $ this ->_has_operator ($ k ))
@@ -698,10 +698,11 @@ protected function _wh($qb_key, $key, $value = NULL, $type = 'AND ', $escape = N
698698 $ k = substr ($ k , 0 , $ match [0 ][1 ]).($ match [1 ][0 ] === '= ' ? ' IS NULL ' : ' IS NOT NULL ' );
699699 }
700700
701- $ this ->{$ qb_key }[] = array ('condition ' => $ prefix .$ k .$ v , 'escape ' => $ escape );
701+ $ {$ qb_key } = array ('condition ' => $ prefix .$ k , 'value ' => $ v , 'escape ' => $ escape );
702+ $ this ->{$ qb_key }[] = $ {$ qb_key };
702703 if ($ this ->qb_caching === TRUE )
703704 {
704- $ this ->{$ qb_cache_key }[] = array ( ' condition ' => $ prefix . $ k . $ v , ' escape ' => $ escape ) ;
705+ $ this ->{$ qb_cache_key }[] = $ { $ qb_key } ;
705706 $ this ->qb_cache_exists [] = substr ($ qb_key , 3 );
706707 }
707708
@@ -834,6 +835,7 @@ protected function _where_in($key = NULL, $values = NULL, $not = FALSE, $type =
834835
835836 $ where_in = array (
836837 'condition ' => $ prefix .$ key .$ not .' IN( ' .implode (', ' , $ where_in ).') ' ,
838+ 'value ' => NULL ,
837839 'escape ' => $ escape
838840 );
839841
@@ -962,33 +964,34 @@ protected function _like($field, $match = '', $type = 'AND ', $side = 'both', $n
962964 $ v = $ this ->escape_like_str ($ v );
963965 }
964966
965- if ($ side === ' none ' )
967+ switch ($ side )
966968 {
967- $ like_statement = "{ $ prefix } { $ k } { $ not } LIKE ' { $ v } ' " ;
968- }
969- elseif ( $ side === ' before ' )
970- {
971- $ like_statement = "{ $ prefix } { $ k } { $ not } LIKE '% {$ v }' " ;
972- }
973- elseif ( $ side === 'after ' )
974- {
975- $ like_statement = "{ $ prefix } { $ k } { $ not } LIKE ' { $ v } %' " ;
976- }
977- else
978- {
979- $ like_statement = "{ $ prefix } { $ k } { $ not } LIKE '% { $ v } %' " ;
969+ case ' none ' :
970+ $ v = " ' { $ v } ' " ;
971+ break ;
972+ case ' before ' :
973+ $ v = "%' {$ v }' " ;
974+ break ;
975+ case 'after ' :
976+ $ v = " ' { $ v } %' " ;
977+ break ;
978+ case ' both ' :
979+ default :
980+ $ v = " '% { $ v } %' " ;
981+ break ;
980982 }
981983
982984 // some platforms require an escape sequence definition for LIKE wildcards
983985 if ($ escape === TRUE && $ this ->_like_escape_str !== '' )
984986 {
985- $ like_statement .= sprintf ($ this ->_like_escape_str , $ this ->_like_escape_chr );
987+ $ v .= sprintf ($ this ->_like_escape_str , $ this ->_like_escape_chr );
986988 }
987989
988- $ this ->qb_where [] = array ('condition ' => $ like_statement , 'escape ' => $ escape );
990+ $ qb_where = array ('condition ' => "{$ prefix } {$ k } {$ not } LIKE " , 'value ' => $ v , 'escape ' => $ escape );
991+ $ this ->qb_where [] = $ qb_where ;
989992 if ($ this ->qb_caching === TRUE )
990993 {
991- $ this ->qb_cache_where [] = array ( ' condition ' => $ like_statement , ' escape ' => $ escape ) ;
994+ $ this ->qb_cache_where [] = $ qb_where ;
992995 $ this ->qb_cache_exists [] = 'where ' ;
993996 }
994997 }
@@ -1013,6 +1016,7 @@ public function group_start($not = '', $type = 'AND ')
10131016 $ prefix = (count ($ this ->qb_where ) === 0 && count ($ this ->qb_cache_where ) === 0 ) ? '' : $ type ;
10141017 $ where = array (
10151018 'condition ' => $ prefix .$ not .str_repeat (' ' , ++$ this ->qb_where_group_count ).' ( ' ,
1019+ 'value ' => NULL ,
10161020 'escape ' => FALSE
10171021 );
10181022
@@ -1073,6 +1077,7 @@ public function group_end()
10731077 $ this ->qb_where_group_started = FALSE ;
10741078 $ where = array (
10751079 'condition ' => str_repeat (' ' , $ this ->qb_where_group_count --).') ' ,
1080+ 'value ' => NULL ,
10761081 'escape ' => FALSE
10771082 );
10781083
@@ -1433,7 +1438,7 @@ public function count_all_results($table = '', $reset = TRUE)
14331438 // --------------------------------------------------------------------
14341439
14351440 /**
1436- * Get_Where
1441+ * get_where()
14371442 *
14381443 * Allows the where clause, limit and offset to be added directly
14391444 *
@@ -2395,7 +2400,7 @@ protected function _compile_wh($qb_key)
23952400 }
23962401 elseif ($ this ->{$ qb_key }[$ i ]['escape ' ] === FALSE )
23972402 {
2398- $ this ->{$ qb_key }[$ i ] = $ this ->{$ qb_key }[$ i ]['condition ' ];
2403+ $ this ->{$ qb_key }[$ i ] = $ this ->{$ qb_key }[$ i ]['condition ' ].( isset ( $ this ->{ $ qb_key }[ $ i ][ ' value ' ]) ? ' ' . $ this ->{ $ qb_key }[ $ i ][ ' value ' ] : '' ) ;
23992404 continue ;
24002405 }
24012406
@@ -2434,7 +2439,7 @@ protected function _compile_wh($qb_key)
24342439 .' ' .trim ($ matches [3 ]).$ matches [4 ].$ matches [5 ];
24352440 }
24362441
2437- $ this ->{$ qb_key }[$ i ] = implode ('' , $ conditions );
2442+ $ this ->{$ qb_key }[$ i ] = implode ('' , $ conditions ).( isset ( $ this ->{ $ qb_key }[ $ i ][ ' value ' ]) ? ' ' . $ this ->{ $ qb_key }[ $ i ][ ' value ' ] : '' ) ;
24382443 }
24392444
24402445 return ($ qb_key === 'qb_having ' ? "\nHAVING " : "\nWHERE " )
0 commit comments