View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Miles Crawford > Solstice-1440 > Solstice::Database



Annotate this POD


New  1
Open  0
View/Report Bugs
Module Version: 2998   Source  


Solstice::Database - Wrapper around DBI.


  use Solstice::Database;

  my $db = new Solstice::Database()

  # For a read only query that can be sent to any read only servers
  # that are syncronized, or the write master otherwise.
  $db->readQuery("SELECT fname, lname FROM solstice.Person WHERE person_id=?", 15);

  while (my $data_ref = $db->fetchRow()) {
    warn "First: ".$data_ref->{'fname'};
    warn "Last:".$data_ref->{'lname'};

  # For any inserts/updates/deletes, that
  # must go to the master
  $db->writeQuery("INSERT INTO solstice.Person (fname, lname) VALUES (?, ?)", 'Patrick', 'Michaud');

  # Get the id of that person
  my $id = $db->getLastInsertID();

  # Get a read lock (that is, lock other people from reading)

  # Get a write lock (that is, lock other people from writing)

  # Unlock any locks


This object is here to make the database connections reliable and consistent across the Solstice tools source tree. Unlike the most generic methods for database connectivity, these methods are reliable and efficient in the mod_perl environment.

**It is strongly recommended that you use this object to make all of your database connections when programming perl source for the Solstice Tools**


No symbols exported.



Constructor. Creates a database handle and caches it.

readQuery($sqlCommand [, $param]*)

For a read only query that can be sent to any read only servers that are synchronized, or the write master. Dies on error, and returns undef.


Returns the database handle to a slave db. If there are no slaves, returns the master database handle.


Returns a count of slaves available for connecting.


After a read query, fetches a row of results. Returns undef when there aren't any more rows to read, otherwise returns a hash ref.


Return a count of rows returned by the last read query, or undef if a read cursor is not defined.

writeQuery($sql_command [, $param]*)

For any inserts/updates/deletes that must go to the master. Dies on error, and returns undef.


Gets the id of the most recently inserted row.


Gets a read lock (lock other people from reading). Dies on error, and returns undef.


Gets a write lock (lock other people from writing or reading). Dies on error, and returns undef.


Release any table locks. Dies on error, and returns undef.



Private methods


Takes a database handle and returns true or false if it is caught up with the master


Releases the statement handle that was used for reading.


Opens and returns the database handle.


Private functions

_reportErrorAndDie($function, $error, $caller, $sql)

Sends an email to the admin, and dies.

Modules Used

DBI, Date::Dumper, Time::HiRes, Solstice::Configure, Solstice::Email.


Catalyst Group, <>


$Revision: 2998 $


Copyright 1998-2007 Office of Learning Technologies, University of Washington

Licensed under the Educational Community License, Version 1.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

syntax highlighting: