On Dec 26, 5:25 pm, Jason Dixon <[email protected]> wrote:
> On Dec 26, 12:47 pm, Jeremy Evans <[email protected]> wrote:
>
> > On Dec 26, 9:32 am, Jason Dixon <[email protected]> wrote:
>
> > > I'm trying to replace my original queries with bound variables but I'm
> > > doing something wrong. Here's a sample query (with the original
> > > commented out) that ends up returning nothing.
>
> > > #@user = User.filter(:username => session[:user], :site_id => 1).first
> > > ds = User.filter(:username => $u, :site_id => $s)
> > > @user = ds.call(:first, :u => session[:user], :s => 1)
>
> > > Any suggestions?
>
> > You are using global variables, not symbols.  You want:
>
> >   ds = User.filter(:username => :$u, :site_id => :$s)
>
> Is it possible to use bound variables during initialize?

No.  Bound variables/prepared statements are a dataset level feature,
not a model level feature.  You can use the prepared_statements plugin
to use prepared statements at the model level for model creation/
updating/deleting.  For selections, you can call prepare/call on a
model dataset, which works the same way it does for plain datasets.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to