Jim Schueler > NoSQL-PL2SQL > NoSQL::PL2SQL::DBI::MySQL

Download:
NoSQL-PL2SQL-1.21.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

NoSQL::PL2SQL::DBI::MySQL - MySQL driver for NoSQL::PL2SQL

SYNOPSIS ^

  package AnyClass ;
  use base qw( NoSQL::PL2SQL ) ;
  use NoSQL::PL2SQL::DBI::MySQL ;

  ## define a data source
  my $dsn = new NoSQL::PL2SQL::DBI::MySQL $tablename ;

  ## connect
  $dsn->connect( $data_source, $username, $auth, \%attr ) ;

  ## access
  my $object = AnyClass->SQLObject( $dsn, $objectid ) ;

  ## create a data source
  $dsn->loadschema ;

  ## utilities
  $dsn->do('DROP TABLE %s') ;
  $dsn->do('DELETE FROM %s') ;

  my @fetchrows = $dsn->rows_hash('SELECT * FROM %s WHERE objectid=1') ;
  my @fetchrows = $dsn->rows_array('SELECT * FROM %s WHERE objectid=1') ;

DESCRIPTION ^

NoSQL::PL2SQL::DBI::MySQL creates a MySQL database datasource for NoSQL::PL2SQL.

Developers who are comfortable with RDB can design a thin object interface using any number of tools, such as DBIx::Class. NoSQL::PL2SQL is designed for developers of thicker objects that may be more logical and require data flexibility. For these developers, where the database is merely a mechanism for object persistance, NoSQL::PL2SQL provides a simple abstraction with a trivial interface, and great portability.

One of NoSQL::PL2SQL's features is a "universal" table definition that can accomodate arbitrary and indeterminate data structures. This flexibility means that a single table can be used for heterogeneous instantiations of different classes. In many cases, a single table can serve the data needs of an entire application. Consequently, a NoSQL::PL2SQL::DBI object is primarily defined by the tablename using a constructor argument.

The driver object contains only one other property, a database handle, which is defined using the connect() method with the same arguments as the default DBI->connect() method. Otherwise, the default handle is a NoSQL::PL2SQL::DBI::Null object that simply reflects statement arguments, and can be useful for debugging.

This object can also invoke any DBI method. SQL statement arguments do not need to specify a table name which is a property of the driver object. Use the sprintf() notation '%s' intead.

Additionally, NoSQL::PL2SQL::DBI provides versions of DBI->fetchrow_arrayref() and DBI->fetchrow_hashref- rows_array() and rows_hash() respectively. These methods take an SQL statement as an argument, perform preparation and execution, and return the same output as their counterparts.

EXPORT

None by default.

HISTORY ^

0.01

SEE ALSO ^

NoSQL::PL2SQL
NoSQL::PL2SQL::DBI
http://pl2sql.tqis.com/

AUTHOR ^

Jim Schueler, <jim@tqis.com>

COPYRIGHT AND LICENSE ^

Copyright (C) 2012 by Jim Schueler

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.9 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: