Category: Active Record
-
Using IF condition in SELECT in Active Record SQL scope (for Yii)
Instead of a string value use an array to specify different ‘select’ expressions (just a string will get exploded using comma as delimter and there’ll be an error). NB! New variables defined only in SQL query code (with AS) should be defined also in the Model: // AR variables defined in SQL query code public…