Re: [Sqlrelay-discussion] PHP Pear SQLRelay driver patch
Brought to you by:
mused
|
From: Gena01 <ge...@gm...> - 2005-12-09 18:37:48
|
Oops.. just saw that I didn't say that I was running it against Oracle
8.1server.
Gena01
On 12/9/05, Gena01 <ge...@gm...> wrote:
>
> Hi David,
>
> Thanks for the commit. I got 2 more fixes in the attached patch/diff file=
:
> 1. Fixed execute() it was returning the wrong thing and breaking stuff.
> Couldn't do $res->fetchRow() since $res was the wrong object.
> 2. Added support for & and ? per oci8 driver.
>
> NOTE: Please review the big patch for & and ? carefully since it was
> mostly a hack on my part. I might have done some things wrong.
>
> P.S. Now my problem is as following:
> - I got the prepared stuff to work. But my connection was dying. I had to
> enable debugging to get any info. Also weird that it didn't try to create=
a
> new connection once the old one died. Or is there a fixed version since
> 0.36.4?
> - Once I got the debug going I looked at the end of the file and saw it
> was runing out of cursors.
> - I increased it from 5 to 50 and restarted. Now each connection was
> taking up 500Megs of virtual memory. Is there anyway to lower that number=
? I
> changed it down to 10 cursors for now, but it would be nicer to get the
> memory usage down somehow. It just seems like such an overkill. But what =
do
> I know....
>
> Gena01
>
> On 12/9/05, David Muse <dav...@fi...> wrote:
> >
> > Thanks for the fix, I just committed it to CVS. You're right, it shoul=
d
> > be this->$connection. Odd though, that it always worked for me without
> > that fix. I guess I never called a function that needed
> > this->$connection to be set in the cursor after running a query :/
> >
> > Here's how I run prepared statements in my test programs:
> >
> > Bind by name:
> > $res=3D$db->prepare("insert into testtable values
> > (:var1,:var2,:var3,:var4,:var5)");
> > $bindvars=3Darray("var1" =3D> 2,
> > "var2" =3D> "testchar2",
> > "var3" =3D> "testvarchar2",
> > "var4" =3D> "01-JAN-2002",
> > "var5" =3D> "testlong2");
> > $res=3D$db->execute($res,$bindvars);
> >
> > or
> >
> > Bind by position:
> > $res=3D$db->prepare("insert into testtable values
> > (:var1,:var2,:var3,:var4,:var5)");
> > $bindvars=3Darray("1" =3D> 2,
> > "2" =3D> "testchar2",
> > "3" =3D> "testvarchar2",
> > "4" =3D> "01-JAN-2002",
> > "5" =3D> "testlong2");
> > $res=3D$db->execute($res,$bindvars);
> >
> > Note the colon-delimited bind variables. Some databases support bind
> > variables natively (oracle, sybase, msssql server, interbase, db2 and
> > postgresql) and for those databases, sqlrelay uses the native bind
> > syntax. Ie, for sybase/mssqlserver, the query should look like:
> >
> > insert into testtable values (@var1,@var2,@var3,@var4)
> >
> > for DB2:
> >
> > insert into testtable values (?,?,?,?)
> >
> > For databases that don't support bind variables natively, SQL Relay
> > fakes them by rewriting the query. For those databases, you have to us=
e
> > colon-delimited bind variables.
> >
> > MySQL 4.1 (I think) and 5.0 (for sure) support bind variables natively
> > as well, but SQL Relay doesn't yet use those features, so for now, when
> > using mysql, SQL Relay still fakes bind variables. I belive MySQL
> > uses ?'s to denote bind variables, so eventually, when SQL Relay
> > supports native bind variables with MySQL, you'll be able to write
> > queries like:
> >
> > insert into testtable values (?,?,?,?)
> >
> > but for now you have to use colon-delimited names.
> >
> > Hope this helps,
> >
> > David Muse
> > dav...@fi...
> >
> > On Fri, 2005-12-09 at 11:19 -0500, Gena01 wrote:
> > > I found out about SQLRelay recently. So I tried to set it up and get
> > > our stuff running against it. I grabbed the latest stable release fro=
m
> > > download section. It seems that the Pear driver for SQL relay in 26.4
> > > is quite buggy. So i went and pulled the code from cvs. There are
> > > still some bugs in that code that I found and fixed in my copy.
> > >
> > > Specifically:
> > >
> > > function prepare($query)
> > > {
> > > $cursor =3D sqlrcur_alloc($this->connection);
> > > sqlrcur_setResultSetBufferSize($cursor,100);
> > > sqlrcur_prepareQuery($cursor, $query);
> > > return new DB_sqlrelay_cursor($cursor,$connection); <--- no
> > > such variable, should be $this->connection
> > > }
> > >
> > >
> > > What do I need to do to get Prepared Statements to work. Esp in Pear
> > > the ones that look like
> > > SELECT a
> > > FROM table
> > > WHERE id =3D ?
> > >
> > > Thank you,
> > >
> > > Gena01
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> > files
> > for problems? Stop! Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
> > http://ads.osdn.com/?ad_id=3D7637&alloc_id=3D16865&op=3Dclick
> > _______________________________________________
> > Sqlrelay-discussion mailing list
> > Sql...@li...
> > https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion
> >
>
>
>
|