ShabdaModelDocs
[ class tree: ShabdaModelDocs ] [ index: ShabdaModelDocs ] [ all elements ]

Class: DatabaseManager

Source Location: /system/DatabaseManager.php

Class Overview


DatabaseManager manages the database connection and funnels all queries through a central location.


Variables

Methods



Class Details

[line 13]
DatabaseManager manages the database connection and funnels all queries through a central location.

The DatabaseManager Class is a singleton class that handles the connestion to the database for the entire ShabdaModel system. The database connection information is defined in config.php, found on the root level of the application file structure. The API for DatabaseManager is built into static functions so that you don't have to worry about the process of creating a singleton object. DatabaseManager also has an array for observers that use the Observer interface. You can use these observers to log queries and report on errors when they occur. Default functionality records all queries into the system.log.




[ Top ]


Class Variables

static $instance =  null

[line 18]

The holder for the singleton model



Tags:

access:  private

Type:   mixed


[ Top ]

$observers = array()

[line 25]

An array of objects that implement the Observer interface

You can add as many observers to the class as you would like so long as they respond to the call() method.




Tags:

access:  public

Type:   mixed


[ Top ]



Class Methods


static method instance [line 36]

static void instance( )

The Singleton Instance Method

Returns the sole instance of the DatabaseManager class. If it has not been created yet, it will create the object and then initialize it.




Tags:

access:  public


[ Top ]

static method query [line 57]

static void query( $sql)

The Static Query Method

The query static method handles the database query. It calls an internal method to do the work.

DatabaseManager::query expects the SQL for the query as it's only parameter.

Returns the results of mysql_query based on the SQL provided.

  1. $result DatabaseManager::query("SELECT * FROM users");




Tags:

access:  public


Parameters:

   $sql  

[ Top ]

constructor __construct [line 27]

DatabaseManager __construct( )



Tags:

access:  private


[ Top ]

method execute_query [line 73]

void execute_query( $sql)

The Private Execute Query

The private execute_query method handles the actual call to mysql_query. It also triggers the observe() method before the actual database call so that if it fails you will be able to see what the last query you made was.

execute_query expects the SQL for the query as it's only parameter.

Returns the results of mysql_query based on the SQL provided.




Tags:

access:  private


Parameters:

   $sql  

[ Top ]

method initialize [line 88]

void initialize( )

DatabaseManager Initialization

The initialization method sets up the database connection. If the connection fails, it throws an error. This method also assigns any default observers to the observer array. By default it uses the SystemObserver which will record all database queries into the system.log.

execute_query does not accept parameters.




Tags:

access:  private


[ Top ]

method observe [line 104]

void observe( $sql)

DatabaseManager observe

The private observe method loops through the array of observers and sends the requested sql to the Observer's call method.

execute_query does not accept parameters.




Tags:

access:  private


Parameters:

   $sql  

[ Top ]


Documentation generated on Mon, 03 Jan 2011 12:38:08 -0500 by phpDocumentor 1.4.3