Class NAJAX_Events_Storage_MySQL

Description

NAJAX Events Storage MySQL Class.

This class is a NAJAX_Events_Storage successor.

The class allows you to save events information in MySQL database.

Example:

  1. <?php
  2.  
  3. require_once('najax.php');
  4.  
  5. require_once(NAJAX_BASE . '/classes/events/storage/MySQL.class.php');
  6.  
  7. $storage = new NAJAX_Events_Storage_MySQL('server=?;user=?;password=?;database=?;[port=?]');
  8.  
  9. $storage->postEvent('event', 'class');
  10.  
  11. ?>

  • version: 0.4.1.0
  • author: Stanimir Angeloff

Located in /classes/events/storage/MySQL.class.php (line 70)

NAJAX_Events_Storage
   |
   --NAJAX_Events_Storage_MySQL
Variable Summary
string $sqlDatabase
string $sqlPassword
string $sqlPort
string $sqlServer
string $sqlUser
Method Summary
NAJAX_Events_Storage_MySQL NAJAX_Events_Storage_MySQL (string $dsn)
bool cleanEvents ()
void closeConnection (mixed $connection)
string escapeString (mixed $unescapedString, mixed $connection)
array filterEvents (string $event, string $class, [string $filter = null], [int $time = null])
array filterMultipleEvents (array $eventsData)
resource getConnection ()
object A getStorage (string $dsn)
bool postEvent (string $event, string $class, [object $sender = null], [mixed $data = null], [string $filter = null], [int $time = null], [int $lifetime = null])
bool postMultipleEvents (array $eventsData)
Variables
string $sqlDatabase (line 110)

Holds the MySQL database used in the connection string.

  • access: private
bool $sqlOpenNew (line 131)

Indicates whether to open a new connection to the MySQL server if an old one already exists.

  • access: private
string $sqlPassword (line 100)

Holds the MySQL password used in the connection string.

  • access: private
string $sqlPort = 3306 (line 120)

Holds the MySQL port used in the connection string.

  • access: private
string $sqlServer (line 80)

Holds the MySQL server used in the connection string.

  • access: private
string $sqlUser (line 90)

Holds the MySQL user used in the connection string.

  • access: private
Methods
Constructor NAJAX_Events_Storage_MySQL (line 142)

Creates a new instance of the NAJAX_Events_Storage_MySQL class.

  • access: public
NAJAX_Events_Storage_MySQL NAJAX_Events_Storage_MySQL (string $dsn)
  • string $dsn: The data source name and parameters to use when connecting to MySQL.
cleanEvents (line 434)

Deletes old events from the database.

This method is called before calling filterEvents or filterMultipleEvents to delete all expired events from the database.

  • return: true on success, false otherwise.
  • access: public
bool cleanEvents ()

Redefinition of:
NAJAX_Events_Storage::cleanEvents()
Abstract base class method.
closeConnection (line 259)

Closes a MySQL connection link.

  • access: private
void closeConnection (mixed $connection)
escapeString (line 273)

Escapes special characters in the $unescapedString, taking into account the current charset of the connection.

  • access: private
string escapeString (mixed $unescapedString, mixed $connection)
filterEvents (line 475)

Filters the events in the database using a single criteria.

The $event and $class arguments are required for each event. The $filter and $time arguments are optional.

This method calls filterMultipleEvents with the appropriate arguments.

  • return: Sequental array that contains all events that match the supplied criterias, ordered by time (ascending).
  • access: public
array filterEvents (string $event, string $class, [string $filter = null], [int $time = null])
  • string $event: The event name (case-sensitive).
  • string $class: The class that is the source of the event.
  • string $filter: The event filter data (case-insensitive). Using this argument you can filter events with the same name but with different filter data.
  • int $time: The event start time (seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Redefinition of:
NAJAX_Events_Storage::filterEvents()
Abstract base class method.
filterMultipleEvents (line 506)

Filters the events in the database using multiple criterias.

Valid keys for each event are:

  • event - the event name (case-sensitive);
  • className - the class that is the source of the event;
  • filter - the event filter data (case-insensitive); using this argument you can filter events with the same name but with different filter data;
  • time - the event start time (seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

  • return: Sequental array that contains all events that match the supplied criterias, ordered by time (ascending).
  • access: public
array filterMultipleEvents (array $eventsData)
  • array $eventsData: Array containing associative arrays with information for each event.

Redefinition of:
NAJAX_Events_Storage::filterMultipleEvents()
Abstract base class method.
getConnection (line 233)

Creates a MySQL connection link.

  • access: private
resource getConnection ()
getStorage (line 213)

Retrieves a new instance of the NAJAX_Events_Storage_MySQL class.

This method overrides NAJAX_Events_Storage::getStorage.

object A getStorage (string $dsn)
  • string $dsn: The data source name and parameters to use when connecting to MySQL.

Redefinition of:
NAJAX_Events_Storage::getStorage()
Retrieves an instane to the configurated NACLES storage provider.
postEvent (line 317)

Posts a single event to the database.

The $event and $class arguments are required for each event. The $sender, $data, $filter, $time and $lifetime arguments are optional.

In case you have supplied both $class and $sender, then the $sender's class must match the one you've supplied.

This method calls postMultipleEvents with the appropriate arguments.

  • return: true on success, false otherwise.
  • access: public
bool postEvent (string $event, string $class, [object $sender = null], [mixed $data = null], [string $filter = null], [int $time = null], [int $lifetime = null])
  • string $event: The event name (case-sensitive).
  • string $class: The class that is the source of the event.
  • object $sender: The sender object of the event.
  • mixed $data: The data associated with the event.
  • string $filter: The event filter data (case-insensitive). Using this argument you can post events with the same name but with different filter data. The client will respond to them individually.
  • int $time: The event start time (seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
  • int $lifetime: The event lifetime (in seconds).

Redefinition of:
NAJAX_Events_Storage::postEvent()
Abstract base class method.
postMultipleEvents (line 354)

Posts multiple events to the database.

Valid keys for each event are:

  • event - the event name (case-sensitive);
  • className - the class that is the source of the event;
  • sender - the sender object of the event;
  • data - the data associated with the event;
  • filter - the event filter data (case-insensitive); using this key you can post events with the same name but with different filter data; the client will respond to them individually;
  • time - the event start time (seconds since the Unix Epoch (January 1 1970 00:00:00 GMT);
  • lifetime - the event lifetime (in seconds);

  • return: true on success, false otherwise.
  • access: public
bool postMultipleEvents (array $eventsData)
  • array $eventsData: Array containing associative arrays with information for each event.

Redefinition of:
NAJAX_Events_Storage::postMultipleEvents()
Abstract base class method.

Inherited Methods

Inherited From NAJAX_Events_Storage

NAJAX_Events_Storage::cleanEvents()
NAJAX_Events_Storage::filterEvents()
NAJAX_Events_Storage::filterMultipleEvents()
NAJAX_Events_Storage::getStorage()
NAJAX_Events_Storage::postEvent()
NAJAX_Events_Storage::postMultipleEvents()

Documentation generated on Tue, 20 Sep 2005 21:40:11 +0300 by phpDocumentor 1.3.0RC3