Class Klutz_Driver_sql

Description

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

$Horde: klutz/lib/Driver/sql.php,v 1.19 2008/09/08 21:28:18 mrubinsk Exp $

Required parameters:

   'directory'  The main directory the comics are stored in

Located in /lib/Driver/sql.php (line 17)

Klutz_Driver
   |
   --Klutz_Driver_sql
Variable Summary
 string $basedir
 string $subdir
Method Summary
 Klutz_Driver_sql Klutz_Driver_sql ([array $params = array()])
 boolean|PEAR_Error addSum (string $index, timestamp $date, string $data)
 boolean imageExists (string $index, [timestamp $date = null])
 string imageSize (string $index, [timestamp $date = null])
 boolean isUnique (Klutz_Image $image)
 mixed listDates ([timestamp $date = null], [timestamp $oldest = null], [timestamp $newest = null])
 void loadSums ()
 void rebuildSums ()
 boolean removeDate ([timestamp $date = null])
 boolean removeImage (string $index, [timestamp $date = null])
 int|PEAR_Error removeSum ([string $index = null], [timestamp $date = null])
 mixed retrieveImage (string $index, [timestamp $date = null])
 boolean storeImage (string $index, string $image, [ $date = null], timestamp $data)
Variables
string $basedir = null (line 24)

The base directory we store comics in.

string $subdir = 'Ymd' (line 32)

The format for the various subdirectories.

WARNING: DO NOT CHANGE THIS!

$_db = null (line 39)

The MDB2 database object

Methods
Constructor Klutz_Driver_sql (line 46)

Constructs a new SQL storage object.

Klutz_Driver_sql Klutz_Driver_sql ([array $params = array()])
  • array $params: A hash containing connection parameters.
addSum (line 119)

Add a unique identifier for a given image.

  • return: True on success, PEAR_Error on failure.
boolean|PEAR_Error addSum (string $index, timestamp $date, string $data)
  • string $index: The index for the comic
  • timestamp $date: The date of the comic
  • string $data: The md5 of the raw (binary) image data
imageExists (line 337)

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

  • return: False in this driver
boolean imageExists (string $index, [timestamp $date = null])
  • string $index: The index of the comic to check
  • timestamp $date: The date of the comic to check (default today)

Redefinition of:
Klutz_Driver::imageExists()
Find out if we already have a local copy of this image.
imageSize (line 319)

Get the image dimensions for the requested image.

  • return: Attributes for an <img> tag giving height and width
string imageSize (string $index, [timestamp $date = null])
  • string $index: The index of the comic to check
  • timestamp $date: The date of the comic to check (default today)

Redefinition of:
Klutz_Driver::imageSize()
Get the image dimensions for the requested image.
isUnique (line 198)

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.

  • return: True if unique, false otherwise.
boolean isUnique (Klutz_Image $image)
listDates (line 236)

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.

  • return: An array of dates in $subdir format between $oldest and $newest that we have comics for | PEAR_Error
mixed listDates ([timestamp $date = null], [timestamp $oldest = null], [timestamp $newest = null])
  • timestamp $date: The reference date (default today)
  • timestamp $oldest: The earliest possible date to return (default first of the month)
  • timestamp $newest: The latest possible date to return (default last date of the month)

Redefinition of:
Klutz_Driver::listDates()
Gets a list of the dates for which we have comics between $oldest and $newest. In the default driver (no backend) this is just a list of all dates between $oldest and $newest.
loadSums (line 71)

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.

void loadSums ()
rebuildSums (line 80)

Rebuild the table of unique identifiers.

void rebuildSums ()
removeDate (line 444)

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

  • return: True on success, else false
boolean removeDate ([timestamp $date = null])
  • timestamp $date: The date to remove comics for (default today)
removeImage (line 420)

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

  • return: True on success, else false
boolean removeImage (string $index, [timestamp $date = null])
  • string $index: The index of the comic to remove
  • timestamp $date: The date of the comic to remove (default today)
removeSum (line 154)

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.

  • return: number of affected Comics on success, PEAR_Error on failure.
int|PEAR_Error removeSum ([string $index = null], [timestamp $date = null])
  • string $index: Index for the comic to delete. If left out all comics will be assumed.
  • timestamp $date: Date to remove. If left out, assumes all dates.
retrieveImage (line 358)

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

  • return: If the image exists locally, return a Klutz_Image object. If it doesn't, return a string with the URL pointing to the comic.
mixed retrieveImage (string $index, [timestamp $date = null])
  • string $index: The index of the comic to retrieve
  • timestamp $date: The date for which we want $comic

Redefinition of:
Klutz_Driver::retrieveImage()
Retrieve an image from storage. Since there is no local storage this will actually call for the fetching.
storeImage (line 377)

Store an image for later retrieval.

  • return: True on success, false otherwise
boolean storeImage (string $index, string $image, [ $date = null], timestamp $data)
  • string $index: The index of the comic to retrieve
  • string $image: Raw (binary) image data to store
  • timestamp $data: Date to store it under (default today)
  • $date

Redefinition of:
Klutz_Driver::storeImage()
Store an image for later retrieval

Inherited Methods

Inherited From Klutz_Driver

 Klutz_Driver::Klutz_Driver()
 Klutz_Driver::factory()
 Klutz_Driver::imageExists()
 Klutz_Driver::imageSize()
 Klutz_Driver::listDates()
 Klutz_Driver::retrieveImage()
 Klutz_Driver::singleton()
 Klutz_Driver::storeImage()

Documentation generated on Sun, 30 Jan 2011 05:30:35 +0000 by phpDocumentor 1.4.3