0

我试过这个查询。

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: 

有谁知道为什么?

4

1 回答 1

1

你应该刷新 yii 数据库模式缓存:

Yii::app()->cache->flush(); 
于 2013-05-31T07:06:45.550 回答