Hi, I have the following sentence:
$usmarc = UsmarcSubfield::find()
->where(["tag" => 100, "subfield_cd" => "a"])
->orWhere(["tag" => 650, "subfield_cd" => "a"])
->orWhere(["tag" => 250, "subfield_cd" => "a"])
->orWhere(["tag" => 10, "subfield_cd" => 'a'])
->orWhere(["tag" => 20, "subfield_cd" => "a"])
->orWhere(["tag" => 50, "subfield_cd" => ['a', 'b', 'c']])
->orWhere(["tag" => 82, "subfield_cd" => ['a', '2']])
->orWhere(["tag" => 260, "subfield_cd" => ['a', 'b', 'c']])
->orWhere(["tag" => 520, "subfield_cd" => 'a'])
->orWhere(["tag" => 300, "subfield_cd" => ['a', 'b', 'c', 'e']])
->orWhere(["tag" => 541, "subfield_cd" => 'h'])->all();
Which SQL output is
SELECT * FROM `usmarc_subfield_dm` WHERE (((((((((((`tag`=100) AND (`subfield_cd`='a')) OR ((`tag`=650) AND (`subfield_cd`='a'))) OR ((`tag`=250) AND (`subfield_cd`='a'))) OR ((`tag`=10) AND (`subfield_cd`='a'))) OR ((`tag`=20) AND (`subfield_cd`='a'))) OR ((`tag`=50) AND (`subfield_cd` IN ('a', 'b', 'c')))) OR ((`tag`=82) AND (`subfield_cd` IN ('a', '2')))) OR ((`tag`=260) AND (`subfield_cd` IN ('a', 'b', 'c')))) OR ((`tag`=520) AND (`subfield_cd`='a'))) OR ((`tag`=300) AND (`subfield_cd` IN ('a', 'b', 'c', 'e')))) OR ((`tag`=541) AND (`subfield_cd`='h'))
Is so large but the issue is the following: in the view, $usmarc variable only has 6 records, but if I run directly the sentence from console I get
[font=monospace]SELECT * FROM `usmarc_subfield_dm` WHERE (((((((((((`tag`=100) AND (`subfield_cd`='a')) OR ((`tag`=650) AND (`subfield_cd`='a'))) OR ((`tag`=250) AND (`subfield_cd`='a'))
) OR ((`tag`=10) AND (`subfield_cd`='a'))) OR ((`tag`=20) AND (`subfield_cd`='a'))) OR ((`tag`=50) AND (`subfield_cd` IN ('a', 'b', 'c')))) OR ((`tag`=82) AND (`subfield_cd` IN ('a', '2')))) O
R ((`tag`=260) AND (`subfield_cd` IN ('a', 'b', 'c')))) OR ((`tag`=520) AND (`subfield_cd`='a'))) OR ((`tag`=300) AND (`subfield_cd` IN ('a', 'b', 'c', 'e')))) OR ((`tag`=541) AND (`subfield_c
d`='h'));
+-----+-------------+--------------------------------------------------+----------------+
| tag | subfield_cd | description | repeatable_flg |
+-----+-------------+--------------------------------------------------+----------------+
| 10 | a | LC control number | N |
| 20 | a | International Standard Book Number | N |
| 50 | a | Classification number | Y |
| 50 | b | Item number | N |
| 82 | 2 | Edition number | N |
| 82 | a | Classification number | Y |
| 100 | a | Personal name | N |
| 250 | a | Edition statement | N |
| 260 | a | Place of publication, distribution, etc. | Y |
| 260 | b | Name of publisher, distributor, etc. | Y |
| 260 | c | Date of publication, distribution, etc. | Y |
| 300 | a | Extent | Y |
| 300 | b | Other physical details | N |
| 300 | c | Dimensions | Y |
| 300 | e | Accompanying material | N |
| 520 | a | Summary, etc. note | N |
| 541 | h | Purchase price | N |
| 650 | a | Topical term or geographic name as entry element | N |
+-----+-------------+--------------------------------------------------+----------------+
[b]18 rows in set (0.00 sec)[/b]
[/font]
So the model should return the same results but actually isn’t.
Why I’m getting this behavior?
Kind regards.