None
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.
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.
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
Example \s-1URLS\s0
mysql://<user>:<pass>@<host>:<port>/<database_name> mysql://<host>:<port>/<database_name> mysql://<user>@<host>:<port>/<database_name> mysql://<host>/<database_name> oracle://<user>:<pass>@/<database_name> oracle://<user>:<pass>@<host>:<port>/<database_name> sqlite:///<database_file>
Jessica Severin <[email protected]>
* 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 ''AS IS'' 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.
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _
Description: instance creation method Parameter : a hash reference of options same as attribute methods Returntype : instance of this Class (subclass) Exceptions : none
Description: instance creation method Returntype : instance of this Class (subclass) Exceptions : none
Description: initialization method which subclasses can extend Returntype : $self Exceptions : subclass dependent
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://<user>:<pass>@<host>:<port>/<database_name>"); e.g. mysql://<host>:<port>/<database_name> e.g. mysql://<user>@<host>:<port>/<database_name> e.g. mysql://<host>/<database_name> e.g. sqlite:///<database_file> my $class = shift; Exceptions : none
Description: makes a copy of the database configuration. New instance will have its own database connection Returntype : instance of MQdb::Database
Description: connects to database and returns a DBI connection Returntype : DBI database handle Exceptions : none
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
Description: returns the URL of this database with user and password Returntype : string Exceptions : none
Description: returns URL of this database but without user:password used for global referencing and federation systems Returntype : string Exceptions : none
Description: returns XML of this database but without user:password used for global referencing and federation systems Returntype : string Exceptions : none
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
Description : executes SQL statement with "do" and no external parameters Example : $db->do_sql("insert into table1(id, value) values(null,'hello world');"); Parameter : sql statement string with no external parameters Returntype : none Exceptions : none
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