- for (c = 0, cols = PQnfields(res); c < cols; ++c) {
- if (PQgetisnull(res, row, c)) {
- switch (fetch_type) {
- case PHP_PQRES_FETCH_OBJECT:
- add_property_null(data, PQfname(res, c));
- break;
+ if (PQntuples(res) > row) {
+ for (c = 0, cols = PQnfields(res); c < cols; ++c) {
+ if (PQgetisnull(res, row, c)) {
+ switch (fetch_type) {
+ case PHP_PQRES_FETCH_OBJECT:
+ add_property_null(data, PQfname(res, c));
+ break;