[Dbix-class] paging question
Ronald J Kimball
rkimball+dbixclass at pangeamedia.com
Fri Feb 5 21:22:48 GMT 2010
James Marca wrote:
> From reading the docs, starting with
> http://search.cpan.org/~frew/DBIx-Class-0.08115/lib/DBIx/Class/Storage/DBI.pm#DBIx::Class_specific_connection_attributes
> and then linking to http://search.cpan.org/perldoc?DBI#prepare_cached,
> I see this for 'prepare_cached':
>
> Like "prepare" except that the statement handle returned will be
> stored in a hash associated with the $dbh. If another call is made
> to prepare_cached with the same $statement and %attr parameter
> values, then the corresponding cached $sth will be returned without
> contacting the database server.
>
> So if I understand this correctly, what is happening is that
> prepare_cached is caching a statement that depends on both the query
> *and* the attributes of the query. And because my attributes change
> with each $data_rs->search($query) line, I never end up resuing a
> statement handle, right? What I want is to get a prepared statement
> handle reused for a query with different bind values, without having
> to dive down into the DBI connection to do it.
prepare_cached() does what you want. %attrs is the hash of attributes,
such as RaiseError or FetchHashKeyName, not the list of bind values.
The list of bind values isn't even passed to prepare_cached().
Ronald
More information about the DBIx-Class
mailing list