.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 >0, 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "MQdb::Database 3pm" .TH MQdb::Database 3pm "2018-05-06" "perl v5.26.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" MQdb::Database \- Generalized handle on an DBI database handle .SH "DESCRIPTION" .IX Header "DESCRIPTION" Generalized handle on an \s-1DBI\s0 database handle. Used to provide an instance which holds connection information and allows a higher level get_connection/ disconnect logic that persists above the specific \s-1DBI\s0 connections. Also provides a real object for use with the rest of the toolkit. .SH "SUMMARY" .IX Header "SUMMARY" MQdb::Database provides the foundation of the MappedQuery system. Databases are primarily specified with a \s-1URL\s0 format. The \s-1URL\s0 format includes specification of a driver so this single method can select among the supported \s-1DBD\s0 drivers. Currently the system supports \s-1MYSQL,\s0 Oracle, and SQLite. The \s-1URL\s0 also allows the system to provide the foundation for doing federation of persisted objects. Each DBObject contains a pointer to the Database instance where it is stored. With the database \s-1URL\s0 and internal database \s-1ID,\s0 each object is defined in a global space. .PP Attributes of MQdb::Database driver : mysql, oracle, sqlite (default mysql) user : username if the database requires password : password if the database requires host : hostname of the database server machine port : \s-1IP\s0 port of the database if required (mysql default is 3306) dbname : database/schema name on the database server for sqlite, this is the database file .PP Example \s-1URLS\s0 mysql://:@:/ mysql://:/ mysql://@:/ mysql:/// oracle://:@/ oracle://:@:/ sqlite:/// .SH "CONTACT" .IX Header "CONTACT" Jessica Severin .SH "LICENSE" .IX Header "LICENSE" .Vb 10 \& * Software License Agreement (BSD License) \& * MappedQueryDB [MQdb] toolkit \& * copyright (c) 2006\-2009 Jessica Severin \& * All rights reserved. \& * Redistribution and use in source and binary forms, with or without \& * modification, are permitted provided that the following conditions are met: \& * * Redistributions of source code must retain the above copyright \& * notice, this list of conditions and the following disclaimer. \& * * Redistributions in binary form must reproduce the above copyright \& * notice, this list of conditions and the following disclaimer in the \& * documentation and/or other materials provided with the distribution. \& * * Neither the name of Jessica Severin nor the \& * names of its contributors may be used to endorse or promote products \& * derived from this software without specific prior written permission. \& * \& * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS \*(Aq\*(AqAS IS\*(Aq\*(Aq AND ANY \& * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED \& * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE \& * DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS BE LIABLE FOR ANY \& * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES \& * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; \& * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND \& * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \& * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS \& * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .Ve .SH "APPENDIX" .IX Header "APPENDIX" The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _ .SS "new" .IX Subsection "new" .Vb 4 \& Description: instance creation method \& Parameter : a hash reference of options same as attribute methods \& Returntype : instance of this Class (subclass) \& Exceptions : none .Ve .SS "new" .IX Subsection "new" .Vb 3 \& Description: instance creation method \& Returntype : instance of this Class (subclass) \& Exceptions : none .Ve .SS "init" .IX Subsection "init" .Vb 3 \& Description: initialization method which subclasses can extend \& Returntype : $self \& Exceptions : subclass dependent .Ve .SS "new_from_url" .IX Subsection "new_from_url" .Vb 10 \& Description: primary instance creation method \& Parameter : a string in URL format \& Returntype : instance of MQdb::Database \& Examples : my $db = MQdb::Database\->new_from_url("mysql://:@:/"); \& e.g. mysql://:/ \& e.g. mysql://@:/ \& e.g. mysql:/// \& e.g. sqlite:/// \& my $class = shift; \& Exceptions : none .Ve .SS "copy" .IX Subsection "copy" .Vb 3 \& Description: makes a copy of the database configuration. \& New instance will have its own database connection \& Returntype : instance of MQdb::Database .Ve .SS "dbc" .IX Subsection "dbc" .Vb 3 \& Description: connects to database and returns a DBI connection \& Returntype : DBI database handle \& Exceptions : none .Ve .SS "disconnect" .IX Subsection "disconnect" .Vb 5 \& Description: disconnects handle from database, but retains object and \& all information so that it can be reconnected again \& at a later time. \& Returntype : none \& Exceptions : none .Ve .SS "full_url" .IX Subsection "full_url" .Vb 3 \& Description: returns the URL of this database with user and password \& Returntype : string \& Exceptions : none .Ve .SS "url" .IX Subsection "url" .Vb 4 \& Description: returns URL of this database but without user:password \& used for global referencing and federation systems \& Returntype : string \& Exceptions : none .Ve .SS "xml" .IX Subsection "xml" .Vb 4 \& Description: returns XML of this database but without user:password \& used for global referencing and federation systems \& Returntype : string \& Exceptions : none .Ve .SS "execute_sql" .IX Subsection "execute_sql" .Vb 6 \& Description : executes SQL statement with external parameters and placeholders \& Example : $db\->execute_sql("insert into table1(id, value) values(?,?)", $id, $value); \& Parameter[1] : sql statement string \& Parameter[2..] : optional parameters for the SQL statement \& Returntype : none \& Exceptions : none .Ve .SS "do_sql" .IX Subsection "do_sql" .Vb 5 \& Description : executes SQL statement with "do" and no external parameters \& Example : $db\->do_sql("insert into table1(id, value) values(null,\*(Aqhello world\*(Aq);"); \& Parameter : sql statement string with no external parameters \& Returntype : none \& Exceptions : none .Ve .SS "fetch_col_value" .IX Subsection "fetch_col_value" .Vb 7 \& Arg (1) : $sql (string of SQL statement with place holders) \& Arg (2...) : optional parameters to map to the placehodlers within the SQL \& Example : $value = $self\->fetch_col_value($db, "select some_column from my_table where id=?", $id); \& Description: General purpose function to allow fetching of a single column from a single row. \& Returntype : scalar value \& Exceptions : none \& Caller : within subclasses to easy development .Ve