我试过了这个问题。
SELECT * FROM(
SELECT DISTINCT ('Kegiatan - ' || coalesce(e.nama,'')) caption, l.id_event id,'e'::text AS berita_type
FROM event e
LEFT JOIN lokasi_pengamatan l ON l.id_event=e.id_event
LEFT JOIN users_location u ON l.id_lokasi_pengamatan=u.id_lokasi_pengamatan
WHERE
1=1
AND l.status = TRUE
AND e.status = TRUE
AND e.e_deleted_at IS NULL
AND l.lp_deleted_at IS NULL
)t1
UNION ALL
SELECT * FROM(
SELECT DISTINCT coalesce(e.nama,'') || ' - ' || coalesce(l.nama,'') caption, l.id_lokasi_pengamatan id, 'lp'::text AS berita_type
FROM event e
LEFT JOIN lokasi_pengamatan l ON l.id_event=e.id_event
LEFT JOIN users_location u ON l.id_lokasi_pengamatan=u.id_lokasi_pengamatan
WHERE
1=1
AND l.status = TRUE
AND e.status = TRUE
AND e.e_deleted_at IS NULL
AND l.lp_deleted_at IS NULL
)t2
ORDER BY berita_type ASC, id DESC, caption ASC
通过Postgre Manager执行时查询OK,但在通过CDbCommand
执行时引发错误。
SQLSTATE[25P02]: In failed sql transaction: 7 ERROR: current transaction is aborted, commands ignored until end of transaction block. The SQL statement executed was:
谁知道为什么?
答案 0 :(得分:1)
您应该刷新yii数据库架构缓存:
Yii::app()->cache->flush();