NAME

CGI::Wiki::Store::Database - parent class for database storage backends for CGI::Wiki

REQUIRES

Time::Piece for making timestamps.

SYNOPSIS

Can't see yet why you'd want to use the backends directly, but:

# See below for parameter details.
my $backend = CGI::Wiki::Store::MySQL->new( %config );

METHODS

new
  my $store = CGI::Wiki::Store::MySQL->new( dbname => "wiki",
					    dbuser => "wiki",
					    dbpass => "wiki",
				   checksum_method => \&md5_hex );

dbname, dbuser and checksum_method parameters are mandatory. If you want defaults done for you then get at it via CGI::Wiki instead. dbpass isn't mandatory, but you'll want to supply it unless your authentication method doesn't require it.

retrieve_node
my $content = $backend->retrieve_node($node);

Returns the current (raw Wiki language) contents of the specified node. The node parameter is mandatory.

verify_checksum
my $ok = $backend->verify_checksum($node, $checksum);

Sees whether your checksum is current for the given node. Returns true if so, false if not.

NOTE: Be aware that when called directly and without locking, this might not be accurate, since there is a small window between the checking and the returning where the node might be changed, so don't rely on it for safe commits; use write_node for that. It can however be useful when previewing edits, for example.

write_node_after_locking
$backend->write_node_after_locking($node, $content)
    or handle_error();

Writes the specified content into the specified node. Making sure that locking/unlocking/transactions happen is left up to you (or your chosen subclass). This method shouldn't really be used directly as it might overwrite someone else's changes. Croaks on error but otherwise returns true.

delete_node
$backend->delete_node($node);

Deletes the node (whether it exists or not), croaks on error. Again, doesn't do any kind of locking. You probably don't want to let anyone except Wiki admins call this. Removes all the node's history as well.

list_recent_changes
# Changes in last 7 days.
my @nodes = $backend->list_recent_changes( days => 7 );

# Changes since a given time.
my @nodes = $backend->list_recent_changes( since => 1036235131 );

# Most recent change and its details.
my @nodes = $backend->list_recent_changes( days => 1 );
print "Node:          $nodes[0]{name}";
print "Last modified: $nodes[0]{last_modified}";
print "Comment:       $nodes[0]{comment}";

Returns results as an array, in reverse chronological order. Each element of the array is a reference to a hash with the following entries:

  • name: the name of the node

  • last_modified: the timestamp of when it was last modified

  • comment: the comment (if any) that was attached to the node last time it was modified

Note that adding comments isn't implemented properly yet, so those will always be the blank string at the moment.

list_all_nodes
my @nodes = $backend->list_all_nodes();

Returns a list containing the name of every existing node. The list won't be in any kind of order; do any sorting in your calling script.

dbh
my $dbh = $store->dbh;

Returns the database handle belonging to this storage backend instance.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 31:

=over without closing =back