Re: [Sqlrelay-discussion] php, bind variables and postgresql
Brought to you by:
mused
|
From: David M. <dav...@fi...> - 2008-11-10 22:26:11
|
There are 2 solutions; use postgresql native bind format or add fakebinds=yes to the string attribute of the connection tag in your sqlrelay.conf file. Prior to version 8.0, postgres did not support bind variables so sqlrelay faked them by rewriting the query. These days, sqlrelay attempts to use postgres's native binds, but you can override that and fall back to the old behavior using fakebinds=yes. If you want to use native postgresql binds, you'll need to rewrite your queries, replacing :assetid with a ? and then in the inputBind call, you'll need to refer to each bind variable by number rather than name. For example: sqlrcur_prepareQuery($cur,"select * from sq_ast where assetid=? and otherid=?"); sqlrcur_inputBind($cur,"1","43"); sqlrcur_inputBind($cur,"2","100"); Either way should work. On Tue, 2008-11-11 at 08:50 +1100, Chris wrote: > Martin Fleurke wrote: > > Chris schreef: > >> sqlrcur_prepareQuery($cur,"select * from sq_ast where assetid=:assetid"); > >> sqlrcur_inputBind($cur,"assetid","43"); > >> ERROR: syntax error at or near ":" at character 36 > >> STATEMENT: select * from sq_ast where assetid=:assetid > >> > >> I'm sure I'm missing something really simple but can't work out what > >> it is. Any suggestions very welcome. > >> > > > > Try > > > > sqlrcur_inputBind($cur,":assetid","43"); > > > > ?? > > > > (The colon should be in the name of the bindvar.) > > I got the same thing as before (postgres throwing an error). > > Could I have done something wrong with the compiling/configuring (though > I'm not really sure what it could be).. ? > _____________________________________________________________ Veteran's Day Domain Sales: Hosting + Domain = US$5.95/year Offer Ends: Nov 12, 2008. http://www.doteasy.com |