📄 simple.pm
字号:
## $Id: Simple.pm,v 1.12 2006/06/11 09:34:12 gomor Exp $#package DBIx::SQLite::Simple;use strict;use warnings;use Carp;our $VERSION = '0.33';require DBI;require Class::Gomor::Array;our @ISA = qw(Class::Gomor::Array);our @AS = qw( db _dbh);__PACKAGE__->cgBuildIndices;__PACKAGE__->cgBuildAccessorsScalar(\@AS);our $Dbo;=head1 NAMEDBIx::SQLite::Simple - easy access to SQLite databases using objects=head1 ATTRIBUTES=over 4=item B<db>Used to store the filename containing the SQLite database.=back=head1 METHODS=over 4=item B<new>(db => 'filename.db')Object creator. Takes one argument, and sets the global variable $Dbo to the newly created database handler.=cutsub new { my $self = shift->SUPER::new(@_); confess('Usage: new(db => $db)') unless $self->db; my $dbh = DBI->connect( 'dbi:SQLite:dbname='. $self->db, '', '', { RaiseError => 0, PrintError => 0, PrintWarn => 0, AutoCommit => 0, }, ) or croak("new: ". $DBI::errstr); $self->_dbh($dbh); $Dbo = $self;}=item B<commit>Changes made on created database are not automatically commited. You must call this method if you want to commit pending changes.=cutsub commit { my $self = shift; $self->_dbh->commit if $self->_dbh;}=item B<close>When you're done using the database, you can disconnect from it. This method will not commit changes, so do it before closing.=cutsub close { my $self = shift; $self->_dbh->disconnect if $self->_dbh; $self->_dbh(undef);}sub DESTROY { my $self = shift; if ($self->_dbh) { $self->commit; $self->close; }}=back=head1 AUTHORPatrice E<lt>GomoRE<gt> Auffret=head1 COPYRIGHT AND LICENSECopyright (c) 2005-2006, Patrice E<lt>GomoRE<gt> AuffretYou may distribute this module under the terms of the Artistic license.See LICENSE.Artistic file in the source distribution archive.=cut1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -