Class SQLHelper

Description

Class used for handling any SQL Statement, which is meant as DB abstraction layer.

It caches loaded - unprepared - Statments for performance issues.

NOTE: There are two super-global Replacer that are automatically appended.

  • 'CID' will be taken from the environment if you do NOT pass it
  • 'DB_PREFIX' will always be added

  • version: $Id: SQLHelper.php,v 1.2 2006/11/26 22:04:33 kpapst Exp $
  • copyright: Copyright (C) 2002-2006 Kevin Papst
  • author: Kevin Papst
  • license: GNU Public License


			
Method Summary
SQLHelper SQLHelper (DatabaseConnection $dbConnection)
void execute ( $sql)
int insert ( $sql)
void loadAndPrepareStatement ( $name,  $values)
void loadStatement ( $name)
void prepareStatement ( $statement, [ $values = array()])
Methods
Constructor SQLHelper (line 57)

Initializes the SQLHelper with the required Database Connection.

SQLHelper SQLHelper (DatabaseConnection $dbConnection)
execute (line 117)

Executes the SQL Statement and returns the Result.

Normaly used for Select, Update, Delete ...

void execute ( $sql)
  • $sql
getConnection (line 133)

Get the DB Connection.

  • return: the DB Connection that is used
DatabaseConnection getConnection ()
insert (line 125)

Executes the Insert Statement and returns the generated ID.

  • return: the Database ID
int insert ( $sql)
  • $sql
loadAndPrepareStatement (line 109)

Simple wrapper for

.

void loadAndPrepareStatement ( $name,  $values)
  • $name
  • $values
loadStatement (line 93)

Loads and returns the Statement. If this statement was loaded before, it will be served directly from the Cache.

void loadStatement ( $name)
  • $name
prepareStatement (line 71)

Prepares the given Statement by replacing all found {REPLACER} with the values of the submitted values array.

For example you have the SQL: Select * from {TABLE} where id='{ID}'

You would pass an array like this: array('TABLE' => 'item_1', 'ID' => '-1')

void prepareStatement ( $statement, [ $values = array()])
  • $statement
  • $values

Documentation generated by phpDocumentor 1.3.1