[Dbix-class] Setting additional attributes in bind_param

John Napiorkowski jjn1056 at yahoo.com
Tue Nov 14 22:39:47 GMT 2006


Hi,

I'm trying to pass some additional 'hinting'
information to the sql statement throught the dbi
bind_param method.  In 'straight' dbi procedural code
I might write something like:

my $update_sql	= q[

  update videos.content
  set content=?
  where catalog_id=? encoding_id=? format_id=?
];
	
my $sth   = $dbh->prepare($update_sql);

$sth->bind_param(1,$file, {pg_type =>
DBD::Pg::PG_BYTEA });
$sth->bind_param(2,$self->catalog_id());
$sth->bind_param(3,$self->encoding_id());
$sth->bind_param(4,$self->format_id());

$sth->execute();

Now I can see we are using SQL::Abstract to create the
SQL and bind lists which we pass straight to execute
in 
DBIx::Class::Storage::DBI.pm in the _execute method. 
So we'd need to change this someway if we want to do
binds with attributes and hinting.

In the docs for SQL::Abstract, it says we can do this
by passing a 'bindtype='columns' when we instantiate
the object.  The main drawback is that we need to loop
through the parameter bindings instead of just passing
it all to dbi excute, but in this case that sort of
flexibility is something I want.

In DBIx::Class::Storage::DBI.pm I find a couple of
methods that might help.  It looks like I can pass
some SQL::Abstract options to the connection method,
but right now these are limited to qw/limit_dialect
quote_char name_sep/.

I don't think it would be too hard to patch
DBIx::Class::Storage::DBI.pm so that you could pass
some hints to the bind_param method.  I think the
biggest choice would be to figure out how to set
and/or store the hinting info.  I'd be inclined to
have it in the column metadata, under a key called,
"bind_attributes" or something like that but I'm not
sure if that will interfere with some other future
plans for extension.

Otherwise it looks to me like it would just be 10 or
so lines of code in one class to make it work.

Thoughts or comments?  

Thank you,
John


 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com



More information about the Dbix-class mailing list