Order By an arbitrary expression
$children = CompanyAccountCatalog::find()
    ->where("companyId=$companyId")
    ->andWhere($parentId > 0 ?"parentId=$parentId" :"parentId<=0 OR parentId is null")
    ->orderBy(new Expression("apAccountId asc, (apAccountId IS NOT NULL OR apAccountId>0) DESC"))->all();

 

About

Software Development Manager, Architect

Categories: HINTS (tehnice) |

Leave a Reply

Your email address will not be published. Required fields are marked *

[TOP]