0
如何在Yii中使用MySQL編寫此查詢?在Yii中將SQL Server查詢轉換爲MySQL
Yii::app()->db->createCommand()
->select("C.[id], C.[name], C.[family], C.[mobile]
, Stuff((
SELECT ', ' + (contact_group.name)
FROM contact_grouping AS CGG , contact_group
WHERE CGG.contact = C.Id AND CGG.[group] = contact_group.id
FOR XML PATH(''), TYPE
).value('.', 'NVARCHAR(MAX)'), 1, 2, '') AS [groups]")
->from("contact AS c")
->where("C.[user] = {$UID} AND C.[attr] = ".self::ATTR_NORMAL.$con)