Thread: how to use $result->ruseltStatus

how to use $result->ruseltStatus

From
Randall Perry
Date:
I want to make sure queries returned aren't empty. Tried this:
   $conn = Pg::connectdb("dbname=$db");   $res  = $conn->exec("$q");   $result_status = $res->resultStatus;
($result_status!= PGRES_EMPTY_QUERY) ? print "query not empty\n" :
 
print "query empty\n";

But it returns '2' (not sure which constant it is, but it's not
PGRES_EMPTY_QUERY) on empty queries.

What's the right use of this property?


-- 
Randy Perry
sysTame
Mac Consulting/Sales




Re: how to use $result->ruseltStatus

From
Tom Lane
Date:
Randall Perry <rgp@systame.com> writes:
> I want to make sure queries returned aren't empty.

Check the number of rows returned (after checking for OK
resultStatus).

> But it returns '2' (not sure which constant it is, but it's not
> PGRES_EMPTY_QUERY) on empty queries.

PGRES_EMPTY_QUERY means you sent an empty string as the query, eg$conn->exec("");
This is pretty useless, and is distinguished only for historical
reasons...
        regards, tom lane