@@ -327,7 +327,7 @@ public function from($from)
327327 * @param string wether not to try to escape identifiers
328328 * @return object
329329 */
330- public function join ($ table , $ cond , $ type = '' , $ escape = TRUE )
330+ public function join ($ table , $ cond , $ type = '' , $ escape = NULL )
331331 {
332332 if ($ type !== '' )
333333 {
@@ -347,6 +347,8 @@ public function join($table, $cond, $type = '', $escape = TRUE)
347347 // in the protect_identifiers to know whether to add a table prefix
348348 $ this ->_track_aliases ($ table );
349349
350+ is_bool ($ escape ) OR $ escape = $ this ->_protect_identifiers ;
351+
350352 // Split multiple conditions
351353 if ($ escape === TRUE && preg_match_all ('/\sAND\s|\sOR\s/i ' , $ cond , $ m , PREG_SET_ORDER | PREG_OFFSET_CAPTURE ))
352354 {
@@ -888,7 +890,7 @@ public function group_by($by)
888890 * @param bool
889891 * @return object
890892 */
891- public function having ($ key , $ value = '' , $ escape = TRUE )
893+ public function having ($ key , $ value = '' , $ escape = NULL )
892894 {
893895 return $ this ->_having ($ key , $ value , 'AND ' , $ escape );
894896 }
@@ -905,7 +907,7 @@ public function having($key, $value = '', $escape = TRUE)
905907 * @param bool
906908 * @return object
907909 */
908- public function or_having ($ key , $ value = '' , $ escape = TRUE )
910+ public function or_having ($ key , $ value = '' , $ escape = NULL )
909911 {
910912 return $ this ->_having ($ key , $ value , 'OR ' , $ escape );
911913 }
@@ -923,13 +925,15 @@ public function or_having($key, $value = '', $escape = TRUE)
923925 * @param bool
924926 * @return object
925927 */
926- protected function _having ($ key , $ value = '' , $ type = 'AND ' , $ escape = TRUE )
928+ protected function _having ($ key , $ value = '' , $ type = 'AND ' , $ escape = NULL )
927929 {
928930 if ( ! is_array ($ key ))
929931 {
930932 $ key = array ($ key => $ value );
931933 }
932934
935+ is_bool ($ escape ) OR $ escape = $ this ->_protect_identifiers ;
936+
933937 foreach ($ key as $ k => $ v )
934938 {
935939 $ prefix = (count ($ this ->qb_having ) === 0 ) ? '' : $ type ;
@@ -1057,14 +1061,16 @@ public function offset($offset)
10571061 // --------------------------------------------------------------------
10581062
10591063 /**
1060- * The "set" function. Allows key/value pairs to be set for inserting or updating
1064+ * The "set" function.
1065+ *
1066+ * Allows key/value pairs to be set for inserting or updating
10611067 *
10621068 * @param mixed
10631069 * @param string
10641070 * @param bool
10651071 * @return object
10661072 */
1067- public function set ($ key , $ value = '' , $ escape = TRUE )
1073+ public function set ($ key , $ value = '' , $ escape = NULL )
10681074 {
10691075 $ key = $ this ->_object_to_array ($ key );
10701076
@@ -1073,16 +1079,12 @@ public function set($key, $value = '', $escape = TRUE)
10731079 $ key = array ($ key => $ value );
10741080 }
10751081
1082+ is_bool ($ escape ) OR $ escape = $ this ->_protect_identifiers ;
1083+
10761084 foreach ($ key as $ k => $ v )
10771085 {
1078- if ($ escape === FALSE )
1079- {
1080- $ this ->qb_set [$ this ->protect_identifiers ($ k )] = $ v ;
1081- }
1082- else
1083- {
1084- $ this ->qb_set [$ this ->protect_identifiers ($ k , FALSE , TRUE )] = $ this ->escape ($ v );
1085- }
1086+ $ this ->qb_set [$ this ->protect_identifiers ($ k , FALSE , $ escape )] = ($ escape )
1087+ ? $ this ->escape ($ v ) : $ v ;
10861088 }
10871089
10881090 return $ this ;
@@ -1288,7 +1290,7 @@ protected function _insert_batch($table, $keys, $values)
12881290 * @param bool
12891291 * @return object
12901292 */
1291- public function set_insert_batch ($ key , $ value = '' , $ escape = TRUE )
1293+ public function set_insert_batch ($ key , $ value = '' , $ escape = NULL )
12921294 {
12931295 $ key = $ this ->_object_to_array_batch ($ key );
12941296
@@ -1297,6 +1299,8 @@ public function set_insert_batch($key, $value = '', $escape = TRUE)
12971299 $ key = array ($ key => $ value );
12981300 }
12991301
1302+ is_bool ($ escape ) OR $ escape = $ this ->_protect_identifiers ;
1303+
13001304 $ keys = array_keys ($ this ->_object_to_array (current ($ key )));
13011305 sort ($ keys );
13021306
@@ -1328,7 +1332,7 @@ public function set_insert_batch($key, $value = '', $escape = TRUE)
13281332
13291333 foreach ($ keys as $ k )
13301334 {
1331- $ this ->qb_keys [] = $ this ->protect_identifiers ($ k );
1335+ $ this ->qb_keys [] = $ this ->protect_identifiers ($ k, FALSE , $ escape );
13321336 }
13331337
13341338 return $ this ;
@@ -1727,7 +1731,7 @@ public function update_batch($table = '', $set = NULL, $index = NULL)
17271731 * @param bool
17281732 * @return object
17291733 */
1730- public function set_update_batch ($ key , $ index = '' , $ escape = TRUE )
1734+ public function set_update_batch ($ key , $ index = '' , $ escape = NULL )
17311735 {
17321736 $ key = $ this ->_object_to_array_batch ($ key );
17331737
@@ -1736,6 +1740,8 @@ public function set_update_batch($key, $index = '', $escape = TRUE)
17361740 // @todo error
17371741 }
17381742
1743+ is_bool ($ escape ) OR $ escape = $ this ->_protect_identifiers ;
1744+
17391745 foreach ($ key as $ k => $ v )
17401746 {
17411747 $ index_set = FALSE ;
@@ -1747,7 +1753,7 @@ public function set_update_batch($key, $index = '', $escape = TRUE)
17471753 $ index_set = TRUE ;
17481754 }
17491755
1750- $ clean [$ this ->protect_identifiers ($ k2 )] = ($ escape === FALSE ) ? $ v2 : $ this ->escape ($ v2 );
1756+ $ clean [$ this ->protect_identifiers ($ k2, FALSE , $ escape )] = ($ escape === FALSE ) ? $ v2 : $ this ->escape ($ v2 );
17511757 }
17521758
17531759 if ($ index_set === FALSE )
0 commit comments