Jifty::DBI::Handle - Perl extension which is a generic DBI handle
use Jifty::DBI::Handle; my $handle = Jifty::DBI::Handle->new(); $handle->connect( driver => 'mysql', database => 'dbname', host => 'hostname', user => 'dbuser', password => 'dbpassword'); # now $handle isa Jifty::DBI::Handle::mysql
This class provides a wrapper for DBI handles that can also perform a number of additional functions.
Generic constructor
Takes a paramhash and connects to your DBI datasource.
If you created the handle with Jifty::DBI::Handle->new and there is a Jifty::DBI::Handle::(Driver) subclass for the driver you have chosen, the handle will be automatically "upgraded" into that subclass.
This private internal method turns a plain Jifty::DBI::Handle into one of the standard driver-specific subclasses.
Builds a dsn suitable for handing to DBI->connect.
Mandatory arguments:
Optional arguments:
Returns the dsn for this database connection.
Turns on the Database Handle's RaiseError attribute.
Turns on the Database Handle's PrintError attribute.
Takes a boolean argument. If the boolean is true, it will log all SQL statements, as well as their invocation times and execution times.
Returns whether we're currently logging or not as a boolean
add an SQL statement to our query log
Clears out the SQL statement log.
Returns the current SQL statement log as an array of arrays. Each entry is a list of
(Time, Statement, [Bindings], Duration)
Turns on the Database Handle's Autocommit attribute.
disconnect from your DBI datasource
Return the current DBI handle. If we're handed a parameter, make the database handle that.
Takes a table name and a set of key-value pairs in an array. splits the key value pairs, constructs an INSERT statement and performs the insert. Returns the row_id of this row.
Takes a hash with columns: Table, Column, Value PrimaryKeys, and IsSQLFunction. Table, and Column should be obvious, Value is where you set the new value you want the column to have. The primary_keys column should be the lvalue of Jifty::DBI::Record::PrimaryKeys(). Finally IsSQLFunction is set when the Value is a SQL function. For example, you might have ('Value'=>'PASSWORD(string)'), by setting IsSQLFunction that string will be inserted into the query directly rather then as a binding.
Update column COLUMN of table table where the record id = RECORD_ID. if IS_SQL is set, don\'t quote the NEW_VALUE
Execute the SQL string specified in QUERY_STRING
Takes a SELECT query as a string, along with an array of BIND_VALUEs If the select succeeds, returns the first row as an array. Otherwise, returns a Class::ResturnValue object with the failure loaded up.
Returns a hash ref for the bind_param call to identify BLOB types used by the current database for a particular column type.
Returns the database's version.
If argument short is true returns short variant, in other case returns whatever database handle/driver returns. By default returns short version, e.g. '4.1.23' or '8.0-rc4'.
short
Returns empty string on error or if database couldn't return version.
The base implementation uses a SELECT VERSION()
SELECT VERSION()
Returns 1 if the current database's searches are case sensitive by default Returns undef otherwise
Takes a column, operator and value. performs the magic necessary to make your database treat this clause as case insensitive.
Returns a column operator value triple.
Tells Jifty::DBI to begin a new SQL transaction. This will temporarily suspend Autocommit mode.
Emulates nested transactions, by keeping a transaction stack depth.
Tells Jifty::DBI to commit the current SQL transaction. This will turn Autocommit mode back on.
Tells Jifty::DBI to abort the current SQL transaction. This will turn Autocommit mode back on.
If this method is passed a true argument, stack depth is blown away and the outermost transaction is rolled back
Force the handle to rollback. Whether or not we're deep in nested transactions
Return the current depth of the faked nested transaction stack.
takes an SQL SELECT statement and massages it to return ROWS_PER_PAGE starting with FIRST_ROW;
Takes a paramhash of everything Jifty::DBI::Collection's join method takes, plus a parameter called collection that contains a ref to a Jifty::DBI::Collection object'.
join
collection
This performs the join.
takes an incomplete SQL SELECT statement and massages it to return a DISTINCT result set.
Takes a single argument, a message to log.
Currently prints that message to STDERR
When we get rid of the Jifty::DBI::Handle, we need to disconnect from the database
Setting JIFTY_DBQUERY_CALLER environment variable will make Jifty::DBI dump the caller for the SQL queries matching it. See also DBI about setting DBI_PROFILE.
JIFTY_DBQUERY_CALLER
DBI
DBI_PROFILE
Jesse Vincent, jesse@fsck.com
perl(1), Jifty::DBI
To install Jifty::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Jifty::DBI
CPAN shell
perl -MCPAN -e shell install Jifty::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.