Overview

Packages

  • Horde
    • Block
  • Klutz
  • None

Classes

  • Klutz
  • Klutz_Comic
  • Klutz_Comic_Bysize
  • Klutz_Comic_Direct
  • Klutz_Comic_Search
  • Klutz_Driver
  • Klutz_Driver_File
  • Klutz_Driver_Sql
  • Klutz_Image
  • Overview
  • Package
  • Class
  • Tree

Class Klutz_Driver_Sql

Klutz Driver implementation for comics as files with SUM info stored in SQL database.

Required parameters:

'directory'  The main directory the comics are stored in
Klutz_Driver
Extended by Klutz_Driver_Sql
Package: Klutz
Author: Marcus I. Ryan marcus@riboflavin.net
Author: Florian Steinel fsteinel@klutz.horde.flonet.net
Located at Driver/Sql.php
Methods summary
public
# Klutz_Driver_sql( array $params = array() )

Constructs a new SQL storage object.

Constructs a new SQL storage object.

Parameters

$params
A hash containing connection parameters.
public
# loadSums( )

We do nothing in this function for the SQL driver since we grab the info on demand from the database. We keep the function here, however to honor our 'interface' since we call this function from various places in the client code.

We do nothing in this function for the SQL driver since we grab the info on demand from the database. We keep the function here, however to honor our 'interface' since we call this function from various places in the client code.

public
# rebuildSums( )

Rebuild the table of unique identifiers.

Rebuild the table of unique identifiers.

public boolean|PEAR_Error
# addSum( string $index, timestamp $date, string $data )

Add a unique identifier for a given image.

Add a unique identifier for a given image.

Parameters

$index
The index for the comic
$date
The date of the comic
$data
The md5 of the raw (binary) image data

Returns

boolean|PEAR_Error
True on success, PEAR_Error on failure.
public integer|PEAR_Error
# removeSum( string $index = null, timestamp $date = null )

Remove the unique identifier for the given comic and/or date. If both are passed, removes the uid for that comic and date. If only a comic is passed, removes all uids for that comic. If only a date is passed removes uids for all comics on that date. If neither is passed, all uids are wiped out.

Remove the unique identifier for the given comic and/or date. If both are passed, removes the uid for that comic and date. If only a comic is passed, removes all uids for that comic. If only a date is passed removes uids for all comics on that date. If neither is passed, all uids are wiped out.

Parameters

$index
<p>Index for the comic to delete. If left out all comics will be assumed.</p>
$date
Date to remove. If left out, assumes all dates.

Returns

integer|PEAR_Error
number of affected Comics on success, PEAR_Error on failure.
public boolean
# isUnique( Klutz_Image $image )

Determine if the image passed is a unique image (one we don't already have).

Determine if the image passed is a unique image (one we don't already have).

This allows for $days = random, etc., but keeps us from getting the same comic day after day.

Parameters

$image
Raw (binary) image data.

Returns

boolean
True if unique, false otherwise.
public mixed
# listDates( timestamp $date = null, timestamp $oldest = null, timestamp $newest = null )

Get a list of the dates for which we have comics between $oldest and $newest. Only returns dates we have at least one comic for.

Get a list of the dates for which we have comics between $oldest and $newest. Only returns dates we have at least one comic for.

Parameters

$date
The reference date (default today)
$oldest
<p>The earliest possible date to return (default first of the month)</p>
$newest
<p>The latest possible date to return (default last date of the month)</p>

Returns

mixed

An array of dates in $subdir format between $oldest and $newest that we have comics for | PEAR_Error

Overrides

Klutz_Driver::listDates()
public string
# imageSize( string $index, timestamp $date = null )

Get the image dimensions for the requested image.

Get the image dimensions for the requested image.

Parameters

$index
The index of the comic to check
$date
The date of the comic to check (default today)

Returns

string
Attributes for an tag giving height and width

Overrides

Klutz_Driver::imageSize()
public boolean
# imageExists( string $index, timestamp $date = null )

Find out if we already have a local copy of this image.

Find out if we already have a local copy of this image.

Parameters

$index
The index of the comic to check
$date
The date of the comic to check (default today)

Returns

boolean
False in this driver

Overrides

Klutz_Driver::imageExists()
public mixed
# retrieveImage( string $index, timestamp $date = null )

Retrieve an image from storage. Make sure the image exists first with imageExists().

Retrieve an image from storage. Make sure the image exists first with imageExists().

Parameters

$index
The index of the comic to retrieve
$date
The date for which we want $comic

Returns

mixed

If the image exists locally, return a Klutz_Image object. If it doesn't, return a string with the URL pointing to the comic.

Overrides

Klutz_Driver::retrieveImage()
public boolean
# storeImage( string $index, string $image, timestamp $date = null )

Store an image for later retrieval.

Store an image for later retrieval.

Parameters

$index
The index of the comic to retrieve
$image
Raw (binary) image data to store
$date
$data Date to store it under (default today)

Returns

boolean
True on success, false otherwise

Overrides

Klutz_Driver::storeImage()
public boolean
# removeImage( string $index, timestamp $date = null )

Remove an image from the storage system (including its unique ID).

Remove an image from the storage system (including its unique ID).

Parameters

$index
The index of the comic to remove
$date
The date of the comic to remove (default today)

Returns

boolean
True on success, else false
public boolean
# removeDate( timestamp $date = null )

Remove all images from the storage system (including unique IDs) for a given date.

Remove all images from the storage system (including unique IDs) for a given date.

Parameters

$date
The date to remove comics for (default today)

Returns

boolean
True on success, else false
Methods inherited from Klutz_Driver
factory()
Properties summary
public string $basedir

The base directory we store comics in.

The base directory we store comics in.

# null
public string $subdir

The format for the various subdirectories. WARNING: DO NOT CHANGE THIS!

The format for the various subdirectories. WARNING: DO NOT CHANGE THIS!

# 'Ymd'
public mixed $_db

The MDB2 database object

The MDB2 database object

# null
API documentation generated by ApiGen