.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "DBD::Mock 3pm" .TH DBD::Mock 3pm "2015-06-07" "perl v5.20.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBD::Mock \- Mock database driver for testing .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use DBI; \& \& # connect to your as normal, using \*(AqMock\*(Aq as your driver name \& my $dbh = DBI\->connect( \*(AqDBI:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq ) \& || die "Cannot create handle: $DBI::errstr\en"; \& \& # create a statement handle as normal and execute with parameters \& my $sth = $dbh\->prepare( \*(AqSELECT this, that FROM foo WHERE id = ?\*(Aq ); \& $sth\->execute( 15 ); \& \& # Now query the statement handle as to what has been done with it \& my $mock_params = $sth\->{mock_params}; \& print "Used statement: ", $sth\->{mock_statement}, "\en", \& "Bound parameters: ", join( \*(Aq, \*(Aq, @{ $mock_params } ), "\en"; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Testing with databases can be tricky. If you are developing a system married to a single database then you can make some assumptions about your environment and ask the user to provide relevant connection information. But if you need to test a framework that uses \s-1DBI,\s0 particularly a framework that uses different types of persistence schemes, then it may be more useful to simply verify what the framework is trying to do \*(-- ensure the right \s-1SQL\s0 is generated and that the correct parameters are bound. \f(CW\*(C`DBD::Mock\*(C'\fR makes it easy to just modify your configuration (presumably held outside your code) and just use it instead of \f(CW\*(C`DBD::Foo\*(C'\fR (like DBD::Pg or DBD::mysql) in your framework. .PP There is no distinct area where using this module makes sense. (Some people may successfully argue that this is a solution looking for a problem...) Indeed, if you can assume your users have something like DBD::AnyData or DBD::SQLite or if you do not mind creating a dependency on them then it makes far more sense to use these legitimate driver implementations and test your application in the real world \*(-- at least as much of the real world as you can create in your tests... .PP And if your database handle exists as a package variable or something else easily replaced at test-time then it may make more sense to use Test::MockObject to create a fully dynamic handle. There is an excellent article by chromatic about using Test::MockObject in this and other ways, strongly recommended. (See \*(L"\s-1SEE ALSO\*(R"\s0 for a link) .SS "How does it work?" .IX Subsection "How does it work?" \&\f(CW\*(C`DBD::Mock\*(C'\fR comprises a set of classes used by \s-1DBI\s0 to implement a database driver. But instead of connecting to a datasource and manipulating data found there it tracks all the calls made to the database handle and any created statement handles. You can then inspect them to ensure what you wanted to happen actually happened. For instance, say you have a configuration file with your database connection information: .PP .Vb 4 \& [DBI] \& dsn = DBI:Pg:dbname=myapp \& user = foo \& password = bar .Ve .PP And this file is read in at process startup and the handle stored for other procedures to use: .PP .Vb 1 \& package ObjectDirectory; \& \& my ( $DBH ); \& \& sub run_at_startup { \& my ( $class, $config ) = @_; \& $config ||= read_configuration( ... ); \& my $dsn = $config\->{DBI}{dsn}; \& my $user = $config\->{DBI}{user}; \& my $pass = $config\->{DBI}{password}; \& $DBH = DBI\->connect( $dsn, $user, $pass ) || die ...; \& } \& \& sub get_database_handle { \& return $DBH; \& } .Ve .PP A procedure might use it like this (ignoring any error handling for the moment): .PP .Vb 1 \& package My::UserActions; \& \& sub fetch_user { \& my ( $class, $login ) = @_; \& my $dbh = ObjectDirectory\->get_database_handle; \& my $sql = q{ \& SELECT login_name, first_name, last_name, creation_date, num_logins \& FROM users \& WHERE login_name = ? \& }; \& my $sth = $dbh\->prepare( $sql ); \& $sth\->execute( $login ); \& my $row = $sth\->fetchrow_arrayref; \& return ( $row ) ? User\->new( $row ) : undef; \& } .Ve .PP So for the purposes of our tests we just want to ensure that: .IP "1. The right \s-1SQL\s0 is being executed" 4 .IX Item "1. The right SQL is being executed" .PD 0 .IP "2. The right parameters are bound" 4 .IX Item "2. The right parameters are bound" .PD .PP Assume whether the \s-1SQL\s0 actually \fBworks\fR or not is irrelevant for this test :\-) .PP To do that our test might look like: .PP .Vb 3 \& my $config = ObjectDirectory\->read_configuration( ... ); \& $config\->{DBI}{dsn} = \*(AqDBI:Mock:\*(Aq; \& ObjectDirectory\->run_at_startup( $config ); \& \& my $login_name = \*(Aqfoobar\*(Aq; \& my $user = My::UserActions\->fetch_user( $login_name ); \& \& # Get the handle from ObjectDirectory; \& # this is the same handle used in the \& # \*(Aqfetch_user()\*(Aq procedure above \& my $dbh = ObjectDirectory\->get_database_handle(); \& \& # Ask the database handle for the history \& # of all statements executed against it \& my $history = $dbh\->{mock_all_history}; \& \& # Now query that history record to \& # see if our expectations match reality \& is(scalar(@{$history}), 1, \*(AqCorrect number of statements executed\*(Aq ; \& \& my $login_st = $history\->[0]; \& like($login_st\->statement, \& qr/SELECT login_name.*FROM users WHERE login_name = ?/sm, \& \*(AqCorrect statement generated\*(Aq ); \& \& my $params = $login_st\->bound_params; \& is(scalar(@{$params}), 1, \*(AqCorrect number of parameters bound\*(Aq); \& is($params\->[0], $login_name, \*(AqCorrect value for parameter 1\*(Aq ); \& \& # Reset the handle for future operations \& $dbh\->{mock_clear_history} = 1; .Ve .PP The list of properties and what they return is listed below. But in an overall view: .IP "\(bu" 4 A database handle contains the history of all statements created against it. Other properties set for the handle (e.g., 'PrintError', 'RaiseError') are left alone and can be queried as normal, but they do not affect anything. (A future feature may track the sequence/history of these assignments but if there is no demand it probably will not get implemented.) .IP "\(bu" 4 A statement handle contains the statement it was prepared with plus all bound parameters or parameters passed via \f(CW\*(C`execute()\*(C'\fR. It can also contain predefined results for the statement handle to 'fetch', track how many fetches were called and what its current record is. .SS "A Word of Warning" .IX Subsection "A Word of Warning" This may be an incredibly naive implementation of a \s-1DBD.\s0 But it works for me ... .SH "DBD::Mock" .IX Header "DBD::Mock" Since this is a normal \s-1DBI\s0 statement handle we need to expose our tracking information as properties (accessed like a hash) rather than methods. .SS "Database Driver Properties" .IX Subsection "Database Driver Properties" .IP "\fBmock_connect_fail\fR" 4 .IX Item "mock_connect_fail" This is a boolean property which when set to true (\f(CW1\fR) will not allow \s-1DBI\s0 to connect. This can be used to simulate a \s-1DSN\s0 error or authentication failure. This can then be set back to false (\f(CW0\fR) to resume normal \s-1DBI\s0 operations. Here is an example of how this works: .Sp .Vb 2 \& # install the DBD::Mock driver \& my $drh = DBI\->install_driver(\*(AqMock\*(Aq); \& \& $drh\->{mock_connect_fail} = 1; \& \& # this connection will fail \& my $dbh = DBI\->connect(\*(Aqdbi:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq) || die "Cannot connect"; \& \& # this connection will throw an exception \& my $dbh = DBI\->connect(\*(Aqdbi:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq, { RaiseError => 1 }); \& \& $drh\->{mock_connect_fail} = 0; \& \& # this will work now ... \& my $dbh = DBI\->connect(...); .Ve .Sp This feature is conceptually different from the 'mock_can_connect' attribute of the \f(CW$dbh\fR in that it has a driver-wide scope, where 'mock_can_connect' is handle-wide scope. It also only prevents the initial connection, any \f(CW$dbh\fR handles created prior to setting 'mock_connect_fail' to true (\f(CW1\fR) will still go on working just fine. .IP "\fBmock_data_sources\fR" 4 .IX Item "mock_data_sources" This is an \s-1ARRAY\s0 reference which holds fake data sources which are returned by the Driver and Database Handle's \f(CW\*(C`data_source()\*(C'\fR method. .IP "\fBmock_add_data_sources\fR" 4 .IX Item "mock_add_data_sources" This takes a string and adds it to the 'mock_data_sources' attribute. .SS "Database Handle Properties" .IX Subsection "Database Handle Properties" .IP "\fBmock_all_history\fR" 4 .IX Item "mock_all_history" Returns an array reference with all history (a.k.a. \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR) objects created against the database handle in the order they were created. Each history object can then report information about the \s-1SQL\s0 statement used to create it, the bound parameters, etc.. .IP "\fBmock_all_history_iterator\fR" 4 .IX Item "mock_all_history_iterator" Returns a \f(CW\*(C`DBD::Mock::StatementTrack::Iterator\*(C'\fR object which will iterate through the current set of \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR object in the history. See the \fBDBD::Mock::StatementTrack::Iterator\fR documentation below for more information. .IP "\fBmock_clear_history\fR" 4 .IX Item "mock_clear_history" If set to a true value all previous statement history operations will be erased. This \fBincludes\fR the history of currently open handles, so if you do something like: .Sp .Vb 4 \& my $dbh = get_handle( ... ); \& my $sth = $dbh\->prepare( ... ); \& $dbh\->{mock_clear_history} = 1; \& $sth\->execute( \*(AqFoo\*(Aq ); .Ve .Sp You will have no way to learn from the database handle that the statement parameter 'Foo' was bound. .Sp This is useful mainly to ensure you can isolate the statement histories from each other. A typical sequence will look like: .Sp .Vb 8 \& set handle to framework \& perform operations \& analyze mock database handle \& reset mock database handle history \& perform more operations \& analyze mock database handle \& reset mock database handle history \& ... .Ve .IP "\fBmock_can_connect\fR" 4 .IX Item "mock_can_connect" This statement allows you to simulate a downed database connection. This is useful in testing how your application/tests will perform in the face of some kind of catastrophic event such as a network outage or database server failure. It is a simple boolean value which defaults to on, and can be set like this: .Sp .Vb 2 \& # turn the database off \& $dbh\->{mock_can_connect} = 0; \& \& # turn it back on again \& $dbh\->{mock_can_connect} = 1; .Ve .Sp The statement handle checks this value as well, so something like this will fail in the expected way: .Sp .Vb 2 \& $dbh = DBI\->connect( \*(AqDBI:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq ); \& $dbh\->{mock_can_connect} = 0; \& \& # blows up! \& my $sth = eval { $dbh\->prepare( \*(AqSELECT foo FROM bar\*(Aq ) }); \& if ( $@ ) { \& # Here, $DBI::errstr = \*(AqNo connection present\*(Aq \& } .Ve .Sp Turning off the database after a statement prepare will fail on the statement \f(CW\*(C`execute()\*(C'\fR, which is hopefully what you would expect: .Sp .Vb 1 \& $dbh = DBI\->connect( \*(AqDBI:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq ); \& \& # ok! \& my $sth = eval { $dbh\->prepare( \*(AqSELECT foo FROM bar\*(Aq ) }); \& $dbh\->{mock_can_connect} = 0; \& \& # blows up! \& $sth\->execute; .Ve .Sp Similarly: .Sp .Vb 1 \& $dbh = DBI\->connect( \*(AqDBI:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq ); \& \& # ok! \& my $sth = eval { $dbh\->prepare( \*(AqSELECT foo FROM bar\*(Aq ) }); \& \& # ok! \& $sth\->execute; \& \& $dbh\->{mock_can_connect} = 0; \& \& # blows up! \& my $row = $sth\->fetchrow_arrayref; .Ve .Sp Note: The handle attribute \f(CW\*(C`Active\*(C'\fR and the handle method \f(CW\*(C`ping\*(C'\fR will behave according to the value of \f(CW\*(C`mock_can_connect\*(C'\fR. So if \f(CW\*(C`mock_can_connect\*(C'\fR were to be set to 0 (or off), then both \f(CW\*(C`Active\*(C'\fR and \f(CW\*(C`ping\*(C'\fR would return false values (or 0). .IP "\fBmock_add_resultset( \e@resultset | \e%sql_and_resultset )\fR" 4 .IX Item "mock_add_resultset( @resultset | %sql_and_resultset )" This stocks the database handle with a record set, allowing you to seed data for your application to see if it works properly.. Each recordset is a simple arrayref of arrays with the first arrayref being the fieldnames used. Every time a statement handle is created it asks the database handle if it has any resultsets available and if so uses it. .Sp Here is a sample usage, partially from the test suite: .Sp .Vb 11 \& my @user_results = ( \& [ \*(Aqlogin\*(Aq, \*(Aqfirst_name\*(Aq, \*(Aqlast_name\*(Aq ], \& [ \*(Aqcwinters\*(Aq, \*(AqChris\*(Aq, \*(AqWinters\*(Aq ], \& [ \*(Aqbflay\*(Aq, \*(AqBobby\*(Aq, \*(AqFlay\*(Aq ], \& [ \*(Aqalincoln\*(Aq, \*(AqAbe\*(Aq, \*(AqLincoln\*(Aq ], \& ); \& my @generic_results = ( \& [ \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq ], \& [ \*(Aqthis_one\*(Aq, \*(Aqthat_one\*(Aq ], \& [ \*(Aqthis_two\*(Aq, \*(Aqthat_two\*(Aq ], \& ); \& \& my $dbh = DBI\->connect( \*(AqDBI:Mock:\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq ); \& $dbh\->{mock_add_resultset} = \e@user_results; # add first resultset \& $dbh\->{mock_add_resultset} = \e@generic_results; # add second resultset \& my ( $sth ); \& eval { \& $sth = $dbh\->prepare( \*(AqSELECT login, first_name, last_name FROM foo\*(Aq ); \& $sth\->execute(); \& }; \& \& # this will fetch rows from the first resultset... \& my $row1 = $sth\->fetchrow_arrayref; \& my $user1 = User\->new( login => $row\->[0], \& first => $row\->[1], \& last => $row\->[2] ); \& is( $user1\->full_name, \*(AqChris Winters\*(Aq ); \& \& my $row2 = $sth\->fetchrow_arrayref; \& my $user2 = User\->new( login => $row\->[0], \& first => $row\->[1], \& last => $row\->[2] ); \& is( $user2\->full_name, \*(AqBobby Flay\*(Aq ); \& ... \& \& my $sth_generic = $dbh\->prepare( \*(AqSELECT foo, bar FROM baz\*(Aq ); \& $sth_generic\->execute; \& \& # this will fetch rows from the second resultset... \& my $row = $sth\->fetchrow_arrayref; .Ve .Sp You can also associate a resultset with a particular \s-1SQL\s0 statement instead of adding them in the order they will be fetched: .Sp .Vb 8 \& $dbh\->{mock_add_resultset} = { \& sql => \*(AqSELECT foo, bar FROM baz\*(Aq, \& results => [ \& [ \*(Aqfoo\*(Aq, \*(Aqbar\*(Aq ], \& [ \*(Aqthis_one\*(Aq, \*(Aqthat_one\*(Aq ], \& [ \*(Aqthis_two\*(Aq, \*(Aqthat_two\*(Aq ], \& ], \& }; .Ve .Sp This will return the given results when the statement '\s-1SELECT\s0 foo, bar \s-1FROM\s0 baz' is prepared. Note that they will be returned \fBevery time\fR the statement is prepared, not just the first. It should also be noted that if you want, for some reason, to change the result set bound to a particular \s-1SQL\s0 statement, all you need to do is add the result set again with the same \s-1SQL\s0 statement and DBD::Mock will overwrite it. .Sp It should also be noted that the \f(CW\*(C`rows\*(C'\fR method will return the number of records stocked in the result set. So if your code/application makes use of the \f(CW\*(C`$sth\->rows\*(C'\fR method for things like \s-1UPDATE\s0 and \s-1DELETE\s0 calls you should stock the result set like so: .Sp .Vb 5 \& $dbh\->{mock_add_resultset} = { \& sql => \*(AqUPDATE foo SET baz = 1, bar = 2\*(Aq, \& # this will appear to have updated 3 rows \& results => [[ \*(Aqrows\*(Aq ], [], [], []], \& }; \& \& # or ... \& \& $dbh\->{mock_add_resultset} = { \& sql => \*(AqDELETE FROM foo WHERE bar = 2\*(Aq, \& # this will appear to have deleted 1 row \& results => [[ \*(Aqrows\*(Aq ], []], \& }; .Ve .Sp Now I admit this is not the most elegant way to go about this, but it works for me for now, and until I can come up with a better method, or someone sends me a patch ;) it will do for now. .Sp If you want a given statement to fail, you will have to use the hashref method and add a 'failure' key. That key can be handed an arrayref with the error number and error string, in that order. It can also be handed a hashref with two keys \- errornum and errorstring. If the 'failure' key has no useful value associated with it, the errornum will be '1' and the errorstring will be 'Unknown error'. .IP "\fBmock_get_info\fR" 4 .IX Item "mock_get_info" This attribute can be used to set up values for \fIget_info()\fR. It takes a hashref of attribute_name/value pairs. See \s-1DBI\s0 for more information on the information types and their meaning. .IP "\fBmock_session\fR" 4 .IX Item "mock_session" This attribute can be used to set a current DBD::Mock::Session object. For more information on this, see the DBD::Mock::Session docs below. This attribute can also be used to remove the current session from the \f(CW$dbh\fR simply by setting it to \f(CW\*(C`undef\*(C'\fR. .IP "\fBmock_last_insert_id\fR" 4 .IX Item "mock_last_insert_id" This attribute is incremented each time an \s-1INSERT\s0 statement is passed to \f(CW\*(C`prepare\*(C'\fR on a per-handle basis. It's starting value can be set with the 'mock_start_insert_id' attribute (see below). .Sp .Vb 1 \& $dbh\->{mock_start_insert_id} = 10; \& \& my $sth = $dbh\->prepare(\*(AqINSERT INTO Foo (foo, bar) VALUES(?, ?)\*(Aq); \& \& $sth\->execute(1, 2); \& # $dbh\->{mock_last_insert_id} == 10 \& \& $sth\->execute(3, 4); \& # $dbh\->{mock_last_insert_id} == 11 .Ve .Sp For more examples, please refer to the test file \fIt/025_mock_last_insert_id.t\fR. .IP "\fBmock_start_insert_id\fR" 4 .IX Item "mock_start_insert_id" This attribute can be used to set a start value for the 'mock_last_insert_id' attribute. It can also be used to effectively reset the 'mock_last_insert_id' attribute as well. .Sp This attribute also can be used with an \s-1ARRAY\s0 ref parameter, it's behavior is slightly different in that instead of incrementing the value for every \f(CW\*(C`prepare\*(C'\fR it will only increment for each \f(CW\*(C`execute\*(C'\fR. This allows it to be used over multiple \f(CW\*(C`execute\*(C'\fR calls in a single \f(CW$sth\fR. It's usage looks like this: .Sp .Vb 2 \& $dbh\->{mock_start_insert_id} = [ \*(AqFoo\*(Aq, 10 ]; \& $dbh\->{mock_start_insert_id} = [ \*(AqBaz\*(Aq, 20 ]; \& \& my $sth1 = $dbh\->prepare(\*(AqINSERT INTO Foo (foo, bar) VALUES(?, ?)\*(Aq); \& \& my $sth2 = $dbh\->prepare(\*(AqINSERT INTO Baz (baz, buz) VALUES(?, ?)\*(Aq); \& \& $sth1\->execute(1, 2); \& # $dbh\->{mock_last_insert_id} == 10 \& \& $sth2\->execute(3, 4); \& # $dbh\->{mock_last_insert_id} == 20 .Ve .Sp Note that DBD::Mock's matching of table names in '\s-1INSERT\s0' statements is fairly simple, so if your table names are quoted in the insert statement (\f(CW\*(C`INSERT INTO "Foo"\*(C'\fR) then you need to quote the name for \f(CW\*(C`mock_start_insert_id\*(C'\fR: .Sp .Vb 1 \& $dbh\->{mock_start_insert_id} = [ q{"Foo"}, 10 ]; .Ve .IP "\fBmock_add_parser\fR" 4 .IX Item "mock_add_parser" \&\s-1DBI\s0 provides some simple parsing capabilities for '\s-1SELECT\s0' statements to ensure that placeholders are bound properly. And typically you may simply want to check after the fact that a statement is syntactically correct, or at least what you expect. .Sp But other times you may want to parse the statement as it is prepared rather than after the fact. There is a hook in this mock database driver for you to provide your own parsing routine or object. .Sp The syntax is simple: .Sp .Vb 6 \& $dbh\->{mock_add_parser} = sub { \& my ( $sql ) = @_; \& unless ( $sql =~ /some regex/ ) { \& die "does not contain secret fieldname"; \& } \& }; .Ve .Sp You can also add more than one for a handle. They will be called in order, and the first one to fail will halt the parsing process: .Sp .Vb 2 \& $dbh\->{mock_add_parser} = \e&parse_update_sql; \& $dbh\->{mock_add\-parser} = \e&parse_insert_sql; .Ve .Sp Depending on the 'PrintError' and 'RaiseError' settings in the database handle any parsing errors encountered will issue a \f(CW\*(C`warn\*(C'\fR or \f(CW\*(C`die\*(C'\fR. No matter what the statement handle will be \f(CW\*(C`undef\*(C'\fR. .Sp Instead of providing a subroutine reference you can use an object. The only requirement is that it implements the method \f(CW\*(C`parse()\*(C'\fR and takes a \s-1SQL\s0 statement as the only argument. So you should be able to do something like the following (untested): .Sp .Vb 2 \& my $parser = SQL::Parser\->new( \*(Aqmysql\*(Aq, { RaiseError => 1 } ); \& $dbh\->{mock_add_parser} = $parser; .Ve .IP "\fBmock_data_sources\fR & \fBmock_add_data_sources\fR" 4 .IX Item "mock_data_sources & mock_add_data_sources" These properties will dispatch to the Driver's properties of the same name. .SS "Database Driver Methods" .IX Subsection "Database Driver Methods" .IP "\fBlast_insert_id\fR" 4 .IX Item "last_insert_id" This returns the value of \f(CW\*(C`mock_last_insert_id\*(C'\fR. .PP In order to capture \fIbegin_work()\fR, \fIcommit()\fR, and \fIrollback()\fR, DBD::Mock will create statements for them, as if you had issued them in the appropriate \s-1SQL\s0 command line program. They will go through the standard \fIprepare()\fR\-\fIexecute()\fR cycle, meaning that any custom \s-1SQL\s0 parsers will be triggered and DBD::Mock::Session will need to know about these statements. .IP "\fBbegin_work\fR" 4 .IX Item "begin_work" This will create a statement with \s-1SQL\s0 of \*(L"\s-1BEGIN WORK\*(R"\s0 and no parameters. .IP "\fBcommit\fR" 4 .IX Item "commit" This will create a statement with \s-1SQL\s0 of \*(L"\s-1COMMIT\*(R"\s0 and no parameters. .IP "\fBrollback\fR" 4 .IX Item "rollback" This will create a statement with \s-1SQL\s0 of \*(L"\s-1ROLLBACK\*(R"\s0 and no parameters. .SS "Statement Handle Properties" .IX Subsection "Statement Handle Properties" .IP "\fBActive\fR" 4 .IX Item "Active" Returns true if the handle is a '\s-1SELECT\s0' and has more records to fetch, false otherwise. (From the \s-1DBI.\s0) .IP "\fBmock_statement\fR" 4 .IX Item "mock_statement" The \s-1SQL\s0 statement this statement handle was \f(CW\*(C`prepare\*(C'\fRd with. So if the handle were created with: .Sp .Vb 1 \& my $sth = $dbh\->prepare( \*(AqSELECT * FROM foo\*(Aq ); .Ve .Sp This would return: .Sp .Vb 1 \& SELECT * FROM foo .Ve .Sp The original statement is unmodified so if you are checking against it in tests you may want to use a regex rather than a straight equality check. (However if you use a phrasebook to store your \s-1SQL\s0 externally you are a step ahead...) .IP "\fBmock_fields\fR" 4 .IX Item "mock_fields" Fields used by the statement. As said elsewhere we do no analysis or parsing to find these, you need to define them beforehand. That said, you do not actually need this very often. .Sp Note that this returns the same thing as the normal statement property '\s-1FIELD\s0'. .IP "\fBmock_params\fR" 4 .IX Item "mock_params" Returns an arrayref of parameters bound to this statement in the order specified by the bind type. For instance, if you created and stocked a handle with: .Sp .Vb 3 \& my $sth = $dbh\->prepare( \*(AqSELECT * FROM foo WHERE id = ? AND is_active = ?\*(Aq ); \& $sth\->bind_param( 2, \*(Aqyes\*(Aq ); \& $sth\->bind_param( 1, 7783 ); .Ve .Sp This would return: .Sp .Vb 1 \& [ 7738, \*(Aqyes\*(Aq ] .Ve .Sp The same result will occur if you pass the parameters via \f(CW\*(C`execute()\*(C'\fR instead: .Sp .Vb 2 \& my $sth = $dbh\->prepare( \*(AqSELECT * FROM foo WHERE id = ? AND is_active = ?\*(Aq ); \& $sth\->execute( 7783, \*(Aqyes\*(Aq ); .Ve .Sp The same using named parameters .Sp .Vb 3 \& my $sth = $dbh\->prepare( \*(AqSELECT * FROM foo WHERE id = :id AND is_active = :active\*(Aq ); \& $sth\->bind_param( \*(Aq:id\*(Aq => 7783 ); \& $sth\->bind_param( \*(Aq:active\*(Aq => \*(Aqyes\*(Aq ); .Ve .IP "\fBmock_records\fR" 4 .IX Item "mock_records" An arrayref of arrayrefs representing the records the mock statement was stocked with. .IP "\fBmock_num_records\fR" 4 .IX Item "mock_num_records" Number of records the mock statement was stocked with; if never stocked it is still 0. (Some weirdos might expect undef...) .IP "\fBmock_num_rows\fR" 4 .IX Item "mock_num_rows" This returns the same value as \fImock_num_records\fR. And is what is returned by the \f(CW\*(C`rows\*(C'\fR method of the statement handle. .IP "\fBmock_current_record_num\fR" 4 .IX Item "mock_current_record_num" Current record the statement is on; returns 0 in the instances when you have not yet called \f(CW\*(C`execute()\*(C'\fR and if you have not yet called a \f(CW\*(C`fetch\*(C'\fR method after the execute. .IP "\fBmock_is_executed\fR" 4 .IX Item "mock_is_executed" Whether \f(CW\*(C`execute()\*(C'\fR has been called against the statement handle. Returns 'yes' if so, 'no' if not. .IP "\fBmock_is_finished\fR" 4 .IX Item "mock_is_finished" Whether \f(CW\*(C`finish()\*(C'\fR has been called against the statement handle. Returns 'yes' if so, 'no' if not. .IP "\fBmock_is_depleted\fR" 4 .IX Item "mock_is_depleted" Returns 'yes' if all the records in the recordset have been returned. If no \f(CW\*(C`fetch()\*(C'\fR was executed against the statement, or If no return data was set this will return 'no'. .IP "\fBmock_my_history\fR" 4 .IX Item "mock_my_history" Returns a \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR object which tracks the actions performed by this statement handle. Most of the actions are separately available from the properties listed above, so you should never need this. .SH "DBD::Mock::Pool" .IX Header "DBD::Mock::Pool" This module can be used to emulate Apache::DBI style \s-1DBI\s0 connection pooling. Just as with Apache::DBI, you must enable DBD::Mock::Pool before loading \s-1DBI.\s0 .PP .Vb 3 \& use DBD::Mock qw(Pool); \& # followed by ... \& use DBI; .Ve .PP While this may not seem to make a lot of sense in a single-process testing scenario, it can be useful when testing code which assumes a multi-process Apache::DBI pooled environment. .SH "DBD::Mock::StatementTrack" .IX Header "DBD::Mock::StatementTrack" Under the hood this module does most of the work with a \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR object. This is most useful when you are reviewing multiple statements at a time, otherwise you might want to use the \f(CW\*(C`mock_*\*(C'\fR statement handle attributes instead. .ie n .IP "\fBnew( \fB%params\fB )\fR" 4 .el .IP "\fBnew( \f(CB%params\fB )\fR" 4 .IX Item "new( %params )" Takes the following parameters: .RS 4 .IP "\(bu" 4 \&\fBreturn_data\fR: Arrayref of return data records .IP "\(bu" 4 \&\fBfields\fR: Arrayref of field names .IP "\(bu" 4 \&\fBbound_params\fR: Arrayref of bound parameters .RE .RS 4 .RE .IP "\fBstatement\fR (Statement attribute 'mock_statement')" 4 .IX Item "statement (Statement attribute 'mock_statement')" Gets/sets the \s-1SQL\s0 statement used. .IP "\fBfields\fR (Statement attribute 'mock_fields')" 4 .IX Item "fields (Statement attribute 'mock_fields')" Gets/sets the fields to use for this statement. .IP "\fBbound_params\fR (Statement attribute 'mock_params')" 4 .IX Item "bound_params (Statement attribute 'mock_params')" Gets/set the bound parameters to use for this statement. .IP "\fBreturn_data\fR (Statement attribute 'mock_records')" 4 .IX Item "return_data (Statement attribute 'mock_records')" Gets/sets the data to return when asked (that is, when someone calls 'fetch' on the statement handle). .IP "\fBcurrent_record_num\fR (Statement attribute 'mock_current_record_num')" 4 .IX Item "current_record_num (Statement attribute 'mock_current_record_num')" Gets/sets the current record number. .IP "\fB\f(BIis_active()\fB\fR (Statement attribute 'Active')" 4 .IX Item "is_active() (Statement attribute 'Active')" Returns true if the statement is a \s-1SELECT\s0 and has more records to fetch, false otherwise. (This is from the \s-1DBI,\s0 see the 'Active' docs under '\s-1ATTRIBUTES COMMON TO ALL HANDLES\s0'.) .ie n .IP "\fBis_executed( \fB$yes_or_no\fB )\fR (Statement attribute 'mock_is_executed')" 4 .el .IP "\fBis_executed( \f(CB$yes_or_no\fB )\fR (Statement attribute 'mock_is_executed')" 4 .IX Item "is_executed( $yes_or_no ) (Statement attribute 'mock_is_executed')" Sets the state of the tracker 'executed' flag. .ie n .IP "\fBis_finished( \fB$yes_or_no\fB )\fR (Statement attribute 'mock_is_finished')" 4 .el .IP "\fBis_finished( \f(CB$yes_or_no\fB )\fR (Statement attribute 'mock_is_finished')" 4 .IX Item "is_finished( $yes_or_no ) (Statement attribute 'mock_is_finished')" If set to 'yes' tells the tracker that the statement is finished. This resets the current record number to '0' and clears out the array ref of returned records. .IP "\fB\f(BIis_depleted()\fB\fR (Statement attribute 'mock_is_depleted')" 4 .IX Item "is_depleted() (Statement attribute 'mock_is_depleted')" Returns true if the current record number is greater than the number of records set to return. .IP "\fBnum_fields\fR" 4 .IX Item "num_fields" Returns the number of fields set in the 'fields' parameter. .IP "\fBnum_rows\fR" 4 .IX Item "num_rows" Returns the number of records in the current result set. .IP "\fBnum_params\fR" 4 .IX Item "num_params" Returns the number of parameters set in the 'bound_params' parameter. .ie n .IP "\fBbound_param( \fB$param_num\fB, \f(BI$value\fB )\fR" 4 .el .IP "\fBbound_param( \f(CB$param_num\fB, \f(CB$value\fB )\fR" 4 .IX Item "bound_param( $param_num, $value )" Sets bound parameter \f(CW$param_num\fR to \f(CW$value\fR. Returns the arrayref of currently-set bound parameters. This corresponds to the 'bind_param' statement handle call. .ie n .IP "\fBbound_param_trailing( \fB@params\fB )\fR" 4 .el .IP "\fBbound_param_trailing( \f(CB@params\fB )\fR" 4 .IX Item "bound_param_trailing( @params )" Pushes \f(CW@params\fR onto the list of already-set bound parameters. .IP "\fB\f(BImark_executed()\fB\fR" 4 .IX Item "mark_executed()" Tells the tracker that the statement has been executed and resets the current record number to '0'. .IP "\fB\f(BInext_record()\fB\fR" 4 .IX Item "next_record()" If the statement has been depleted (all records returned) returns undef; otherwise it gets the current recordfor returning, increments the current record number and returns the current record. .IP "\fB\f(BIto_string()\fB\fR" 4 .IX Item "to_string()" Tries to give an decent depiction of the object state for use in debugging. .SH "DBD::Mock::StatementTrack::Iterator" .IX Header "DBD::Mock::StatementTrack::Iterator" This object can be used to iterate through the current set of \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR objects in the history by fetching the 'mock_all_history_iterator' attribute from a database handle. This object is very simple and is meant to be a convience to make writing long test script easier. Aside from the constructor (\f(CW\*(C`new\*(C'\fR) this object has only one method. .Sp .RS 4 \&\fBnext\fR .Sp Calling \f(CW\*(C`next\*(C'\fR will return the next \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR object in the history. If there are no more \f(CW\*(C`DBD::Mock::StatementTrack\*(C'\fR objects available, then this method will return false. .Sp \&\fBreset\fR .Sp This will reset the internal pointer to the beginning of the statement history. .RE .SH "DBD::Mock::Session" .IX Header "DBD::Mock::Session" The DBD::Mock::Session object is an alternate means of specifying the \s-1SQL\s0 statements and result sets for DBD::Mock. The idea is that you can specify a complete 'session' of usage, which will be verified through DBD::Mock. Here is an example: .PP .Vb 10 \& my $session = DBD::Mock::Session\->new(\*(Aqmy_session\*(Aq => ( \& { \& statement => "SELECT foo FROM bar", # as a string \& results => [[ \*(Aqfoo\*(Aq ], [ \*(Aqbaz\*(Aq ]] \& }, \& { \& statement => qr/UPDATE bar SET foo \e= \e\*(Aqbar\e\*(Aq/, # as a reg\-exp \& results => [[]] \& }, \& { \& statement => sub { # as a CODE ref \& my ($SQL, $state) = @_; \& return $SQL eq "SELECT foo FROM bar"; \& }, \& results => [[ \*(Aqfoo\*(Aq ], [ \*(Aqbar\*(Aq ]] \& }, \& { \& # with bound parameters \& statement => "SELECT foo FROM bar WHERE baz = ? AND borg = ?", \& # check exact bound param value, \& # then check it against regexp \& bound_params => [ 10, qr/\ed+/ ], \& results => [[ \*(Aqfoo\*(Aq ], [ \*(Aqbaz\*(Aq ]] \& } \& )); .Ve .PP As you can see, a session is essentially made up a list of \s-1HASH\s0 references we call 'states'. Each state has a 'statement' and a set of 'results'. If DBD::Mock finds a session in the 'mock_session' attribute, then it will pass the current \f(CW$dbh\fR and \s-1SQL\s0 statement to that DBD::Mock::Session. The \s-1SQL\s0 statement will be checked against the 'statement' field in the current state. If it passes, then the 'results' of the current state will get feed to DBD::Mock through the 'mock_add_resultset' attribute. We then advance to the next state in the session, and wait for the next call through DBD::Mock. If at any time the \s-1SQL\s0 statement does not match the current state's 'statement', or the session runs out of available states, an error will be raised (and propagated through the normal \s-1DBI\s0 error handling based on your values for RaiseError and PrintError). .PP Also, as can be seen in the the session element, bound parameters can also be supplied and tested. In this statement, the \s-1SQL\s0 is compared, then when the statement is executed, the bound parameters are also checked. The bound parameters much match in both number of parameters and the parameters themselves, or an error will be raised. .PP As can also be seen in the example above, 'statement' fields can come in many forms. The simplest is a string, which will be compared using \f(CW\*(C`eq\*(C'\fR against the currently running statement. The next is a reg-exp reference, this too will get compared against the currently running statement. The last option is a \s-1CODE\s0 ref, this is sort of a catch-all to allow for a wide range of \s-1SQL\s0 comparison approaches (including using modules like SQL::Statement or SQL::Parser for detailed functional comparisons). The first argument to the \s-1CODE\s0 ref will be the currently active \s-1SQL\s0 statement to compare against, the second argument is a reference to the current state \s-1HASH \s0(in case you need to alter the results, or store extra information). The \s-1CODE\s0 is evaluated in boolean context and throws and exception if it is false. .Sp .RS 4 \&\fBnew ($session_name, \f(CB@session_states\fB)\fR .Sp A \f(CW$session_name\fR can be optionally be specified, along with at least one \f(CW@session_states\fR. If you don't specify a \f(CW$session_name\fR, then a default one will be created for you. The \f(CW@session_states\fR must all be \s-1HASH\s0 references as well, if this conditions fail, an exception will be thrown. .Sp \&\fBverify_statement ($dbh, \f(CB$SQL\fB)\fR .Sp This will check the \f(CW$SQL\fR against the current state's 'statement' value, and if it passes will add the current state's 'results' to the \f(CW$dbh\fR. If for some reason the 'statement' value is bad, not of the prescribed type, an exception is thrown. See above for more details. .Sp \&\fBverify_bound_params ($dbh, \f(CB$params\fB)\fR .Sp If the 'bound_params' slot is available in the current state, this will check the \f(CW$params\fR against the current state's 'bound_params' value. Both number of parameters and the parameters themselves must match, or an error will be raised. .Sp \&\fBreset\fR .Sp Calling this method will reset the state of the session object so that it can be reused. .RE .SH "EXPERIMENTAL FUNCTIONALITY" .IX Header "EXPERIMENTAL FUNCTIONALITY" All functionality listed here is highly experimental and should be used with great caution (if at all). .IP "Error handling in \fImock_add_resultset\fR" 4 .IX Item "Error handling in mock_add_resultset" We have added experimental erro handling in \fImock_add_resultset\fR the best example is the test file \fIt/023_statement_failure.t\fR, but it looks something like this: .Sp .Vb 5 \& $dbh\->{mock_add_resultset} = { \& sql => \*(AqSELECT foo FROM bar\*(Aq, \& results => DBD::Mock\->NULL_RESULTSET, \& failure => [ 5, \*(AqOoops!\*(Aq ], \& }; .Ve .Sp The \f(CW5\fR is the \s-1DBI\s0 error number, and \f(CW\*(AqOoops!\*(Aq\fR is the error string passed to \s-1DBI.\s0 This basically allows you to force an error condition to occur when a given \s-1SQL\s0 statement is execute. We are currently working on allowing more control on the 'when' and 'where' the error happens, look for it in future releases. .IP "Attribute Aliasing" 4 .IX Item "Attribute Aliasing" Basically this feature allows you to alias attributes to other attributes. So for instance, you can alias a commonly expected attribute like 'mysql_insertid' to something DBD::Mock already has like 'mock_last_insert_id'. While you can also just set 'mysql_insertid' yourself, this functionality allows it to take advantage of things like the autoincrementing of the 'mock_last_insert_id' attribute. .Sp Right now this feature is highly experimental, and has been added as a first attempt to automatically handle some of the \s-1DBD\s0 specific attributes which are commonly used/accessed in \s-1DBI\s0 programming. The functionality is off by default so as to not cause any issues with backwards compatibility, but can easily be turned on and off like this: .Sp .Vb 2 \& # turn it on \& $DBD::Mock::AttributeAliasing++; \& \& # turn it off \& $DBD::Mock::AttributeAliasing = 0; .Ve .Sp Once this is turned on, you will need to choose a database specific attribute aliasing table like so: .Sp .Vb 1 \& DBI\->connect(\*(Aqdbi:Mock:MySQL\*(Aq, \*(Aq\*(Aq, \*(Aq\*(Aq); .Ve .Sp The 'MySQL' in the \s-1DSN\s0 will be picked up and the MySQL specific attribute aliasing will be used. .Sp Right now only MySQL is supported by this feature, and even that support is very minimal. Currently the MySQL \f(CW$dbh\fR and \f(CW$sth\fR attributes 'mysql_insertid' are aliased to the \f(CW$dbh\fR attribute 'mock_last_insert_id'. It is possible to add more aliases though, using the \f(CW\*(C`DBD::Mock:_set_mock_attribute_aliases\*(C'\fR function (see the source code for details). .SH "BUGS" .IX Header "BUGS" .ie n .IP "Odd $dbh attribute behavior" 4 .el .IP "Odd \f(CW$dbh\fR attribute behavior" 4 .IX Item "Odd $dbh attribute behavior" When writing the test suite I encountered some odd behavior with some \f(CW$dbh\fR attributes. I still need to get deeper into how \s-1DBD\s0's work to understand what it is that is actually doing wrong. .SH "TO DO" .IX Header "TO DO" .IP "Make \s-1DBD\s0 specific handlers" 4 .IX Item "Make DBD specific handlers" Each \s-1DBD\s0 has its own quirks and issues, it would be nice to be able to handle those issues with DBD::Mock in some way. I have an number of ideas already, but little time to sit down and really flesh them out. If you have any suggestions or thoughts, feel free to email me with them. .IP "Enhance the DBD::Mock::StatementTrack object" 4 .IX Item "Enhance the DBD::Mock::StatementTrack object" I would like to have the DBD::Mock::StatementTrack object handle more of the mock_* attributes. This would encapsulate much of the mock_* behavior in one place, which would be a good thing. .Sp I would also like to add the ability to bind a subroutine (or possibly an object) to the result set, so that the results can be somewhat more dynamic and allow for a more realistic interaction. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\s-1DBI\s0 .PP DBD::NullP, which provided a good starting point .PP Test::MockObject, which provided the approach .PP Test::MockObject article \- .PP Perl Code Kata: Testing Databases \- .SH "DISCUSSION GROUP" .IX Header "DISCUSSION GROUP" We have created a \fBDBD::Mock\fR google group for discussion/questions about this module. .PP .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" .IP "Thanks to Ryan Gerry for his patch in \s-1RT\s0 #26604" 4 .IX Item "Thanks to Ryan Gerry for his patch in RT #26604" .PD 0 .IP "Thanks to Marc Beyer for his patch in \s-1RT\s0 #16951" 4 .IX Item "Thanks to Marc Beyer for his patch in RT #16951" .IP "Thanks to Justin DeVuyst for the mock_connect_fail idea" 4 .IX Item "Thanks to Justin DeVuyst for the mock_connect_fail idea" .ie n .IP "Thanks to Thilo Planz for the code for ""bind_param_inout""" 4 .el .IP "Thanks to Thilo Planz for the code for \f(CWbind_param_inout\fR" 4 .IX Item "Thanks to Thilo Planz for the code for bind_param_inout" .IP "Thanks to Shlomi Fish for help tracking down \s-1RT\s0 Bug #11515" 4 .IX Item "Thanks to Shlomi Fish for help tracking down RT Bug #11515" .ie n .IP "Thanks to Collin Winter for the patch to fix the ""begin_work()"", ""commit()"" and ""rollback()"" methods." 4 .el .IP "Thanks to Collin Winter for the patch to fix the \f(CWbegin_work()\fR, \f(CWcommit()\fR and \f(CWrollback()\fR methods." 4 .IX Item "Thanks to Collin Winter for the patch to fix the begin_work(), commit() and rollback() methods." .ie n .IP "Thanks to Andrew McHarg for ""fetchall_hashref()"", ""fetchrow_hashref()"" and ""selectcol_arrayref()"" methods and tests." 4 .el .IP "Thanks to Andrew McHarg for \f(CWfetchall_hashref()\fR, \f(CWfetchrow_hashref()\fR and \f(CWselectcol_arrayref()\fR methods and tests." 4 .IX Item "Thanks to Andrew McHarg for fetchall_hashref(), fetchrow_hashref() and selectcol_arrayref() methods and tests." .ie n .IP "Thanks to Andrew W. Gibbs for the ""mock_last_insert_ids"" patch and test" 4 .el .IP "Thanks to Andrew W. Gibbs for the \f(CWmock_last_insert_ids\fR patch and test" 4 .IX Item "Thanks to Andrew W. Gibbs for the mock_last_insert_ids patch and test" .ie n .IP "Thanks to Chas Owens for patch and test for the ""mock_can_prepare"", ""mock_can_execute"", and ""mock_can_fetch"" features." 4 .el .IP "Thanks to Chas Owens for patch and test for the \f(CWmock_can_prepare\fR, \f(CWmock_can_execute\fR, and \f(CWmock_can_fetch\fR features." 4 .IX Item "Thanks to Chas Owens for patch and test for the mock_can_prepare, mock_can_execute, and mock_can_fetch features." .PD .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (C) 2004 Chris Winters .PP Copyright (C) 2004\-2007 Stevan Little .PP Copyright (C) 2007 Rob Kinyon .PP Copyright (C) 2011 Mariano Wahlmann .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH "AUTHORS" .IX Header "AUTHORS" Chris Winters .PP Stevan Little .PP Rob Kinyon .PP Mariano Wahlmann