user1488098
user1488098

Reputation: 43

How to get PostgreSQL ROW values with PHP

I have this query:

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

When I'm using PHP to read the result, I use:

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

}

and trying to read "e_name", which is part of the ROW(e.e_name), but I can't succeed.

Need your ideas ... please.

Upvotes: 0

Views: 235

Answers (1)

pomaxa
pomaxa

Reputation: 1746

use pg_fetch_assoc, to retrieve data in asoc-array; But my advice, - use PDO to work with db in PHP.

Upvotes: 1

Related Questions