如何使用PHP获取PostgreSQL ROW值

时间:2012-07-01 15:04:29

标签: php postgresql row

我有这个问题:

SELECT  a.apartment_id, a.building_id, a.apartment_num, a.floor, at.app_type_desc_en AS app_type_desc,
    (SELECT ROW(e.e_name, ot.otype_desc_en)
    FROM    TABLE_TENANTS t INNER JOIN TABLE_OWNERSHIP_TYPES ot ON ot.otype_id=t.ownership_type INNER JOIN TABLE_ENTITIES e ON
t.entity_id = e.entity_id
WHERE   a.apartment_id = t.apartment_id AND t.building_id = a.building_id
ORDER BY t.ownership_type DESC LIMIT 1
    ) AS t_row
    FROM    TABLE_APARTMENTS a INNER JOIN TABLE_APPARTMENT_TYPES at ON at.app_type_id = a.apartment_type LEFT OUTER JOIN TABLE_TENANTS t ON a.building_id = t.building_id AND t.entity_id=1 AND t.status=true LEFT OUTER JOIN TABLE_COMMITTEE_DELEGATE cd ON
     a.building_id = cd.building_id AND cd.entity_id=1 AND cd.status=true
                WHERE a.building_id = 1 AND (t.entity_id=1 OR cd.entity_id=1)
                ORDER BY    a.apartment_num ASC

当我使用PHP读取结果时,我使用:

while($ap = pg_fetch_array($_qry)){ 

}

并尝试读取“e_name”,它是ROW(e.e_name)的一部分,但我无法成功。

需要你的想法......拜托。

1 个答案:

答案 0 :(得分:1)

使用pg_fetch_assoc来检索asoc-array中的数据;但我的建议是,使用PDO在PHP中使用db。