Welcome, Guest Log In

Class Krai_Db_Handler

Class Overview

Abstract database handler class

This class is the basis for any database handlers that may be defined for specific databases. It also provides template functions that may be overridden if desired, and also provides factory methods for the Krai_Struct_Dbquery structs.

Located in /Krai/Db/Handler.php [line 26]



		
				Author(s):
		
API Tags:
Abstract:  

Properties

Methods

[ Top ]
Descendants
Child Class Description
Krai_Db_Handler_Mysql MySQL database handler
Krai_Db_Handler_Pdo PDO database handler

[ Top ]
Property Summary
array   $CONFIG   This variable holds the configuration data loaded by Krai::Setup() and gathered when necessary from Krai::GetConfig() within Krai_Db_Handler::__construct().

[ Top ]
Method Summary
Krai_Db_Handler   __construct()   Constructor.
Krai_Struct_Dbquery_Delete   DeleteQuery()   Generate a query struct for a delete query
Krai_Db_Object   Fetch()   Fetch a database record from a query as an object
array   FetchArray()   Fetch a database record from a query as an array
mixed   FetchOne()   Fetch just one column from the result.
string   GetJoins()   Generate the joins from a table array
Krai_Struct_Dbquery_Insert   InsertQuery()   Generate a query struct for an insert query
void   Process()   Process a query struct according to its type.
mixed   Query()   Execute an SQL query
Krai_Struct_Dbquery_Find   SelectQuery()   Generate a query struct for a find query
void   Transaction()   Transaction controller
Krai_Struct_Dbquery_Update   UpdateQuery()   Generate a query struct for an update query

[ Top ]
Properties
array   $CONFIG = array() [line 35]

This variable holds the configuration data loaded by Krai::Setup() and gathered when necessary from Krai::GetConfig() within Krai_Db_Handler::__construct().

API Tags:
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 45]

  Krai_Db_Handler __construct( )

Constructor.

This function initializes and configures every descendent of this class. It loads the configuration data for the databases.


Information Tags:
Todo:  Add logging

Redefined in descendants as:

[ Top ]
DeleteQuery  [line 187]

  Krai_Struct_Dbquery_Delete DeleteQuery( mixed $tables  )

Generate a query struct for a delete query

This function is a factory for Krai_Struct_Dbquery_Delete structs

Parameters:
mixed   $tables: 

API Tags:
Access:  public


[ Top ]
Fetch  [line 70]

  Krai_Db_Object Fetch( Krai_Db_Query &$qid, Krai_Db_Query $qid  )

Fetch a database record from a query as an object

This function fetches a row from the resultset of a query as an object

Parameters:
Krai_Db_Query   $qid:  The query
Krai_Db_Query   &$qid: 

API Tags:
Return:  The row (false if an error or no more rows)
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
FetchArray  [line 81]

  array FetchArray( Krai_Db_Query &$qid, Krai_Db_Query $qid  )

Fetch a database record from a query as an array

This function fetches a row from the resultset of a query as an associative array.

Parameters:
Krai_Db_Query   $qid:  The query
Krai_Db_Query   &$qid: 

API Tags:
Return:  The row (false if an error or no more rows)
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
FetchOne  [line 91]

  mixed FetchOne( Krai_Db_Query &$qid, Krai_Db_Query $qid  )

Fetch just one column from the result.

This is a holdover from something else that I do not recall. Leaving it for now.

Parameters:
Krai_Db_Query   $qid:  The query
Krai_Db_Query   &$qid: 

API Tags:
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
GetJoins  [line 130]

  string GetJoins( $tables  )

Generate the joins from a table array

This function takes an array of tables and joins and generates sql join fragements from them. Any entry with a numerical key is included as a straight join. Any entry with a string key is processed with the key being the table to do a LEFT JOIN with, and the value being the condition(s) on which to join the table.

This can be overridden by specific adapters to generate the proper syntax if it is not correct for that adapter.

Parameters:
array   $tables:  Array of tables to join

API Tags:
Return:  The join syntax
Access:  protected


[ Top ]
InsertQuery  [line 204]

  Krai_Struct_Dbquery_Insert InsertQuery( mixed $tables  )

Generate a query struct for an insert query

This function is a factory for Krai_Struct_Dbquery_Insert structs

Parameters:
mixed   $tables: 

API Tags:
Access:  public


[ Top ]
Process  [line 102]

  void Process( Krai_Struct_Dbquery $query  )

Process a query struct according to its type.

This function processes a query struct in the proper format for the database adapter.

Parameters:
Krai_Struct_Dbquery   $query: 

API Tags:
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
Query  [line 60]

  mixed Query( string $querytype, string $sql, [ $params = array()]  )

Execute an SQL query

This function executes a specified SQL query using the passed parameters.

Parameters:
string   $querytype:  The type of query that is to be executed (one of "select","insert","update","delete","transaction" -- use "select" for things like DESCRIBE)
string   $sql:  The query to execute
array   $params:  Parameters for the query

API Tags:
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
SelectQuery  [line 170]

  Krai_Struct_Dbquery_Find SelectQuery( mixed $tables  )

Generate a query struct for a find query

This function is a factory for Krai_Struct_Dbquery_Find structs

Parameters:
mixed   $tables: 

API Tags:
Access:  public


[ Top ]
Transaction  [line 113]

  void Transaction( string $_action  )

Transaction controller

This function wraps any transactional abilities the implementing adapter might have.

Parameters:
string   $_action:  One of "start", "commit", or "rollback"

API Tags:
Abstract:  
Access:  public


Redefined in descendants as:

[ Top ]
UpdateQuery  [line 221]

  Krai_Struct_Dbquery_Update UpdateQuery( mixed $tables  )

Generate a query struct for an update query

This function is a factory for Krai_Struct_Dbquery_Update structs

Parameters:
mixed   $tables: 

API Tags:
Access:  public


[ Top ]

Documentation generated on Fri, 25 Jul 2008 15:19:19 -0400 by phpDocumentor 1.4.2
Krai Framework site admin credits sitemap valid xhtml?