@@ -162,7 +162,7 @@ private function checkTargetAttributeExistence($model, $attribute)
162
162
}
163
163
164
164
$ params = $ this ->prepareConditions ($ targetAttribute , $ model , $ attribute );
165
- $ conditions = [$ this ->targetAttributeJunction == 'or ' ? 'or ' : 'and ' ];
165
+ $ conditions = [$ this ->targetAttributeJunction === 'or ' ? 'or ' : 'and ' ];
166
166
167
167
if (!$ this ->allowArray ) {
168
168
foreach ($ params as $ key => $ value ) {
@@ -264,17 +264,14 @@ protected function validateValue($value)
264
264
private function valueExists ($ targetClass , $ query , $ value )
265
265
{
266
266
$ db = $ targetClass ::getDb ();
267
- $ exists = false ;
268
267
269
268
if ($ this ->forceMasterDb && method_exists ($ db , 'useMaster ' )) {
270
- $ exists = $ db ->useMaster (function () use ($ query , $ value ) {
269
+ return $ db ->useMaster (function () use ($ query , $ value ) {
271
270
return $ this ->queryValueExists ($ query , $ value );
272
271
});
273
- } else {
274
- $ exists = $ this ->queryValueExists ($ query , $ value );
275
272
}
276
273
277
- return $ exists ;
274
+ return $ this -> queryValueExists ( $ query , $ value ) ;
278
275
}
279
276
280
277
@@ -290,6 +287,7 @@ private function queryValueExists($query, $value)
290
287
if (is_array ($ value )) {
291
288
return $ query ->count ("DISTINCT [[ $ this ->targetAttribute ]] " ) == count (array_unique ($ value ));
292
289
}
290
+
293
291
return $ query ->exists ();
294
292
}
295
293
@@ -328,7 +326,7 @@ private function applyTableAlias($query, $conditions, $alias = null)
328
326
foreach ($ conditions as $ columnName => $ columnValue ) {
329
327
if (strpos ($ columnName , '( ' ) === false ) {
330
328
$ prefixedColumn = "{$ alias }.[[ " . preg_replace (
331
- '/^ ' . preg_quote ($ alias ) . '\.(.*)$/ ' ,
329
+ '/^ ' . preg_quote ($ alias, ' / ' ) . '\.(.*)$/ ' ,
332
330
'$1 ' ,
333
331
$ columnName ) . ']] ' ;
334
332
} else {
0 commit comments