Re: [Sqlrelay-discussion] =?GB2312?B?tPC4tDogW1NxbHJlbGF5LWRpc2N1?= =?GB2312?B?c3Npb25dIGFib3V0IGlu
Brought to you by:
mused
From: Josh J. <jos...@un...> - 2005-07-21 15:09:25
|
I had a feeling it was more complicated than I thought :) I haven't used sqlrelay enough (I've been using it with PEAR) to have run into this problem myself, but it's something I'll have to deal with too... -- JJ linuxman wrote: >thanks for JJ's quick response ! > >The code below is from the model class of my application: > >.... >if the $query is insert something: > > $this->_masterDb =3D & Db::getDb("sqlrelay",9001); > $this->_cur =3D sqlrcur_alloc( $this->_masterDb ); > sqlrcur_sendQuery( $this->_cur, "set names 'utf8'" ); > sqlrcur_sendQuery( $this->_cur, $query ); > > $result =3D >$this->convertFromEmptySqlRelayResult($this->_cur); > > sqlrcur_sendQuery($this->_cur, "SELECT LAST_INSERT_ID() = as >Insert_ID"); > $row =3D sqlrcur_getRowAssoc($this->_cur); > $this->log->debug("Row is ".LogUtil::format($row= )); > $result->setInsertID($row["Insert_ID"]); > sqlrcon_endSession($this->_masterDb); >=20 >and convertFromEmptySqlRelayResult is here: > > function convertFromEmptySqlRelayResult( $cur ){ > $recordset =3D new EmptyMysqlResultSet_SqlRelay( $cur ); > return $recordset; > } > >And, EmptyMysqlResultSet_SqlRelay is defined as below: > >class EmptyMysqlResultSet_SqlRelay{ > var $fields =3D false; > var $EOF =3D true; > function MoveNext() {return;} > function RecordCount() {return 0;} > function FieldCount() {return 0;} > function EOF(){return TRUE;} > function Close(){return true;} > > function emptyMysqlResultSet_SqlRelay($cur){ > $this->cursor =3D $cur; > } > > function Affected_Rows(){ > return sqlrcur_affectedRows($this->cursor); > } > > function setInsertID($id){ > $this->insert_ID =3D $id; > } > > function getInsertID(){ > return $this->insert_ID; > } >} > >You see, sqlrelay is running port 9001, the query is like "INSERT ....". > >But the problem is, SELECT LAST_INSERT_ID() always return 0, I know thi= s by >watch the log output of "$this->log->debug("Row is >".LogUtil::format($row))". > >Any problem of my codes ? or any other way to get insert id?=20 > >Thanks! > >-----=D3=CA=BC=FE=D4=AD=BC=FE----- >=B7=A2=BC=FE=C8=CB: sql...@li... >[mailto:sql...@li...] =B4=FA=B1=ED Jo= sh Johnson >=B7=A2=CB=CD=CA=B1=BC=E4: 2005=C4=EA7=D4=C221=C8=D5 22:14 >=CA=D5=BC=FE=C8=CB: sql...@li... >=D6=F7=CC=E2: Re: [Sqlrelay-discussion] about insert_id > >try: SELECT LAST_INSERT_ID(); > >-- JJ > >linuxman wrote: > > =20 > >>hi all, >> >>I use mysql+php+adodb in my web application, and want to use sqlrelay=20 >>as database polling. But, I don't know how to get insert id just after=20 >>inserting a record with sqlrelay? you know , there is Insert_ID in=20 >>adodb to get the insert id, but I have not find the same function in=20 >>the php api of sqlrelay. >> >>I used the 0.36 version of sqlrelay. >> >>Any hints? Thanks in advance! >> >>Linuxman >> >> >> >> >> >>------------------------------------------------------- >>SF.Net email is sponsored by: Discover Easy Linux Migration Strategies=20 >> =20 >> >>from IBM. Find simple to follow Roadmaps, straightforward articles,=20 > =20 > >>informative Webcasts and more! Get everything you need to get up to=20 >>speed, fast. http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dcl= ick >>_______________________________________________ >>Sqlrelay-discussion mailing list >>Sql...@li... >>https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion >>=20 >> >> =20 >> > > > > >------------------------------------------------------- >SF.Net email is sponsored by: Discover Easy Linux Migration Strategies f= rom >IBM. Find simple to follow Roadmaps, straightforward articles, informati= ve >Webcasts and more! Get everything you need to get up to speed, fast. >http://ads.osdn.com/?ad_id=3D7477&alloc_id=3D16492&op=3Dclick >_______________________________________________ >Sqlrelay-discussion mailing list >Sql...@li... >https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion > > > > >------------------------------------------------------- >SF.Net email is sponsored by: Discover Easy Linux Migration Strategies >from IBM. Find simple to follow Roadmaps, straightforward articles, >informative Webcasts and more! Get everything you need to get up to >speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id=16492&op=3Dclick >_______________________________________________ >Sqlrelay-discussion mailing list >Sql...@li... >https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion > =20 > |