Thread: PG Problems

PG Problems

From
ALASTAIR JOHN TAYLOR
Date:
Hello,

I was wondering if anyone could help me with a little problem with the Pg
module - I've looked at the manual, but I can't work it out.....

------------------------------------------------------------
$conn = Pg::connectdb("host=...................");

$query = "select timeone from times where racer='$name'";
$result = $conn->exec($query);
$result->print(stdout, ..............);
------------------------------------------------------------

The above code works without any problem, as it should, and prints out a
value, but as soon as I try to add another query/result I get problems...

ie.
--------------------------------------------------------------
$querytwo = "select timetwo from times where racer='$name'";
$resulttwo = $conn->exec($querytwo);

$total = $result + $resulttwo;
$total->print(stout,..........);
--------------------------------------------------------------

I know the problem comes in with the addition of pointers, but I'm at a
dead-end.

Any suggestions?

Thanks in advance, Alastair


Re: PG Problems

From
"Brett W. McCoy"
Date:
On Fri, 21 Apr 2000, ALASTAIR JOHN TAYLOR wrote:

> --------------------------------------------------------------
> $querytwo = "select timetwo from times where racer='$name'";
> $resulttwo = $conn->exec($querytwo);
>
> $total = $result + $resulttwo;

What is it you think this is supposed to be doing?  You are adding the
dereferenced values of these references to get a third reference?  The
values of $result and $resulttwo aren't what you think they are.  They
don't hold the actual value of a query, just a reference to the tuples
returned from the query.  You still need to 'fecth' those results out,
even if you only have one row returned.

Brett W. McCoy
                                              http://www.chapelperilous.net
---------------------------------------------------------------------------
When I first arrived in this country I had only fifteen cents in my pocket
and a willingness to compromise.
        -- Weber cartoon caption



How to get the size of a large object?

From
"Robert B. Easter"
Date:
I use php4 and I'm wondering if there is a way to find out the size of a large
object so that when I call pg_loread($fd, $len), I can set $len to the correct
number of bytes to read in.  Does the database maintain this information
anywhere accessible by a query?  I could store the sizes in a table along with
the oids but would rather not if I don't need to.

Re: How to get the size of a large object?

From
swalker
Date:
This really doesn't answer your question.  But maybe it will achieve the
same result.

PHP has a function called pg_loreadall.  This function reads a large
object and passes it straight through to the browser.

Here is an example
<?
    $db = pg_connect("your connect string");
    pg_exec($db, "begin");
    $result = pg_exec($db, "select image_oid,
                       image_header
                                  from image_mstr
                                 where image_id = 1");
    $row = pg_fetch_row($result, 0);
    pg_exec($db, "end");
    $image_oid = $row[0];
    $header = $row[1];
    pg_exec($db, "begin");
    $fh = pg_loopen($db, $image_oid, "r");
    Header($header);
    pg_loreadall($fh);
    pg_loclose($fh);
    pg_exec($db, "end");
    pg_close($db);
?>

On Fri, 21 Apr 2000, Robert B. Easter wrote:

> I use php4 and I'm wondering if there is a way to find out the size of a large
> object so that when I call pg_loread($fd, $len), I can set $len to the correct
> number of bytes to read in.  Does the database maintain this information
> anywhere accessible by a query?  I could store the sizes in a table along with
> the oids but would rather not if I don't need to.
>