From: Chris W. <la...@us...> - 2005-10-18 01:43:08
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Datasource In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25112 Modified Files: DBI.pm Log Message: OIN-191: pass through database handle attributes specific to a driver Index: DBI.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Datasource/DBI.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** DBI.pm 25 Mar 2005 05:40:02 -0000 1.18 --- DBI.pm 18 Oct 2005 01:43:00 -0000 1.19 *************** *** 81,84 **** --- 81,93 ---- $db->{LongTruncOk} = $full->{long_trunc_ok} || DEFAULT_TRUNC_OK; + my $lc_driver = lc $full->{driver_name}; + foreach my $attrib ( keys %{ $full } ) { + next unless ( $attrib =~ /^$lc_driver/ ); + $db->{ $attrib } = $full->{ $attrib }; + $log->is_debug && + $log->debug( "Assigning driver-specific attribute to db ", + "handle: $attrib -> $full->{ $attrib }" ); + } + my $trace_level = $full->{trace_level} || '0'; $db->trace( $trace_level ); *************** *** 162,166 **** # Define a handle 'win32' that uses Microsoft SQL Server and connects ! # with ODBC [datasource win32] --- 171,175 ---- # Define a handle 'win32' that uses Microsoft SQL Server and connects ! # with ODBC and a custom parameter for the ODBC driver [datasource win32] *************** *** 171,174 **** --- 180,184 ---- username = webuser password = urkelnut + odbc_foo = bar # Request the datasource 'main' from the context object (which in *************** *** 244,249 **** B<dbi_type> ($) ! What database type are you using? Available values are: 'MySQL', ! 'Pg', 'Sybase', 'ASAny', 'Oracle', 'SQLite' and 'MSSQL'. =item * --- 254,259 ---- B<dbi_type> ($) ! What database type are you using? Available case-insensitive values ! are: 'MySQL', 'Pg', 'Sybase', 'ASAny', 'Oracle', 'SQLite' and 'MSSQL'. =item * *************** *** 300,306 **** =back Any errors encountered will throw an exception, usually of the ! L<OpenInteract2::Exception::Datasource|OpenInteract2::Exception::Datasource> ! variety. B<resolve_datasource_info( $name, \%datasource_info )> --- 310,333 ---- =back + You may also define driver-specific parameters that get passed through + to the database handle. A parameter is identified as driver-specific + if it beginns with the driver name. So if we were using L<DBD::Pg> we + might do: + + [datasource main] + type = DBI + dbi_type = Pg + dsn = dbname=oi2 + username = oi2 + password = oi2 + pg_server_prepare = 0 + + which is equivalent to: + + my $dbh = DBI->connect( ... ); + $dbh->{pg_server_prepare} = 0; + Any errors encountered will throw an exception, usually of the ! L<OpenInteract2::Exception::Datasource> variety. B<resolve_datasource_info( $name, \%datasource_info )> |