View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Alex Pavlovic > Catalyst-Model-DBI-SQL-Library-0.15 > Catalyst::Model::DBI::SQL::Library



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.15   Source   Latest Release: Catalyst-Model-DBI-SQL-Library-0.19


Catalyst::Model::DBI::SQL::Library - SQL::Library DBI Model Class


        # use the helper
        create model DBI::SQL::Library DBI::SQL::Library dsn user password
        # lib/MyApp/Model/DBI/SQL/
        package MyApp::Model::DBI::SQL::Library;
        use base 'Catalyst::Model::DBI::SQL::Library';
                dsn                     => 'dbi:Pg:dbname=myapp',
                password                => '',
                user                    => 'postgres',
                options                 => { AutoCommit => 1 },
                sqldir                  => 'root/sql' #optional, will default to $c->path_to ( 'root/sql' ),
                sqlcache                => 1 #can only be used when queries are loaded from file i.e. via scalar passed to load
                sqlcache_use_mtime      => 1 #will use modification time of the file to determine when to refresh the cache

        my $model = $c->model( 'DBI::SQL::Library' );
        my $sql = $model->load ( 'something.sql' ) ;
        #or my $sql = $model->load ( [ <FH> ] );
        #or my $sql = $model->load ( [ $sql_query1, $sql_query2 ] ) )
        my $query = $sql->retr ( 'some_sql_query' );
        #or my $query = $model->sql->retr ( 'some_sql_query );  
        $model->dbh->do ( $query );
        #do something else with $sql ...


This is the SQL::Library model class. It provides access to SQL::Library via sql accessor. Additional caching options are provided for increased performance via sqlcache and sqlcache_use_mtime, these options can only be used when sql strings are stored within a file and loaded by using a scalar value passed to load. The load and parse phase is then bypassed if cached version of the file is found. The use of these options can result in more memory being used but faster access to query data when running under persistent environment such as mod_perl or FastCGI. When sqlcache_use_mtime is in use, last modification time of the file is being referenced upon every cache check. If the modification time has changed query file is then re-loaded. This may slower the application a little bit, but should still be much faster then re-creating the SQL::Library instance on every load. Please refer to the SQL::Library for more information.



Initializes database connection


Initializes SQL::Library instance


Returns the current database handle.


Returns the current SQL::Library instance


Catalyst, DBI


Alex Pavlovic,


This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: