Changes
Title
unchanged
defaultScope
Category
unchanged
How-tos
Yii version
unchanged
Tags
unchanged
create skip bypass disable defaultScope composite condition
Content
changed
[...]
The defaultScope must be able to access these record status fields and that is why we store
their names in $rstatus_fieldname. This enables defaultScope to re-use the same name for all tables.
But in the db, the field's name in tbl1 is tbl1_rstatus_nr.
In tbl2 it is called tbl2_rstatus_nr.
Obviously you could give these fields the same name in all tables and then reference them directly in defaultScope (without using $rstatus_fieldname), but my experience is that defaultScope sometimes have trouble disambiguating the fields if you tunnel through tables via
Relational Query. So I preferin this wiki we regard them as being disambiguat
ing themed in the db
withlike tbl1_rstatus_nr, tbl2..., tbl3... etc.
Here is the base class with the defaultScope():[...]