[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [phpGroupWare-developers] RE: [Phpgroupware-cvs] [18517] hum hum hum
From: |
Sigurd Nes |
Subject: |
RE: [phpGroupWare-developers] RE: [Phpgroupware-cvs] [18517] hum hum hum, please test your code before com |
Date: |
Wed, 14 May 2008 13:37:34 +0200 (MEST) |
> From: Benoit Hamet address@hidden
> Sent: 2008-05-14 12:44:36 CEST
> To: address@hidden
> Subject: Re: [phpGroupWare-developers] RE: [Phpgroupware-cvs] [18517] hum
> hum hum, please test your code before com
>
> Sigurd Nes a écrit :
> > http://svn.savannah.gnu.org/viewvc/trunk/phpgwapi/inc/class.db.inc.php?root=phpgroupware&r1=18482&r2=18517&pathrev=18517
> >
> > _queryID vs _resultid
> >
> > Are you really sure about this one?
> In the case of psql I got the following :
> ADODB_postgres7 Object
> (
> [...]
> [hasInsertID] => 1
> [_resultid] => Resource id #113
> [...]
> [_queryID] => 1
> [...]
> )
>
> and from php.net :
>
> string pg_last_oid ( resource $result )
>
> pg_last_oid() is used to retrieve the OID assigned to an inserted row.
>
> OID field became an optional field from PostgreSQL 7.2 and will not be
> present by default in PostgreSQL 8.1. When the OID field is not present
> in a table, the programmer must use pg_result_status() to check for
> successful insertion.
>
> To get the value of a SERIAL field in an inserted row, it is necessary
> to use the PostgreSQL CURRVAL function, naming the sequence whose last
> value is required. If the name of the sequence is unknown, the
> pg_get_serial_sequence PostgreSQL 8.0 function is necessary.
>
> PostgreSQL 8.1 has a function LASTVAL that returns the value of the most
> recently used sequence in the session. This avoids the need for naming
> the sequence, table or column altogether.
>
> etc...
>
> Anyway, your question make me doubt a little bit, so I do this little try :
> if ($params[0] < 8 || ($params[0] == 8 && $params[1] ==0))
> {
> _debug_array($this->adodb);
> _debug_array($this->adodb->Insert_ID($table, $field));
> $oid = pg_getlastoid($this->adodb->_resultid);
> ...
> _debug_array($Record[0]);
> ...
>
> And I should ask now, Why the hell are you not using the
> $this->adodb->Insert_ID() function ???? the
> _debug_array($this->adodb->Insert_ID($table, $field));
> and _debug_array($Record[0]); return the same values, So I guess that
> I'm pretty sure of using _resultid instead of _queryID, which in any
> case let php5 on error ... So I guess this code was never never tested
> ... At least not with the current code into trunk.
>
> This one returns the right value in my case (psql 7.4), so I don't
> understand why you rewrite it ...
>
So if I understand you right:
$this->adodb->Insert_ID($table, $field); is now working for postgres - any
version?
Regards
Sigurd