Order by Field Type SET

public function getAgenteEnderecoPrincipal()

{


    /*return $this->hasOne(AgenteEndereco::className(), ['agente_id' => 'id'])


            ->where("FIND_IN_SET('Faturamento',tipo)>0");*/


    return $this->hasOne(AgenteEndereco::className(), ['agente_id' => 'id'])


            ->orderBy("FIELD( tipo, 'Correspondência')");


}

but the query is generated as follows:

ERROR: SELECT * FROM agente_endereco WHERE agente_id=2351 [color="#FF0000"]ORDER BY FIELD( tipo, 'Correspondência')[/color]

to work would be correct:

SELECT * FROM sjnew_beta.agente_endereco [color="#006400"]ORDER BY FIELD( tipo, ‘Correspondência’, ‘Cobrança’)[/color]

*Attention to the quotes

Can someone help me?

You can use class Expression

http://www.yiiframework.com/doc-2.0/yii-db-expression.html

See also conversation: https://github.com/yiisoft/yii2/issues/553