Adding Upgrader class to AwlDatabase and tidying things somewhat.

This commit is contained in:
Andrew McMillan 2010-03-10 22:45:13 +13:00
parent 2ee5537258
commit 20f3462673
4 changed files with 65 additions and 5 deletions

View File

@ -5,7 +5,7 @@
* This subpackage provides dialect specific support for PostgreSQL, and
* may, over time, be extended to provide support for other SQL dialects.
*
* See http://wiki.davical.org/w/Coding/PdoDatabase for design and usage information.
* See http://wiki.davical.org/w/Coding/AwlQuery for design and usage information.
*
* @package awl
* @subpackage AwlDatabase
@ -18,7 +18,16 @@
if ( !defined('E_USER_ERROR') ) define('E_USER_ERROR',256);
/**
* The AwlDBDialect class handles
* The AwlDBDialect class handles support for different SQL dialects
*
* This subpackage provides dialect specific support for PostgreSQL, and
* may, over time, be extended to provide support for other SQL dialects.
*
* If you are looking for the place to add support for other SQL dialects,
* this is the class that you should be looking at. You might also look at
* the AwlDatabase class which extends this one, but these are the core
* capabilities which most probably need attention.
*
* @package awl
*/
class AwlDBDialect {

View File

@ -3,7 +3,7 @@
* AwlDatabase query/statement class and associated functions
*
* This subpackage provides some functions that are useful around database
* activity and a AwlDialect, AwlDatabase and AwlStatement classes to simplify
* activity and a AwlDBDialect, AwlDatabase and AwlStatement classes to simplify
* handling of database queries and provide some access for a limited
* ability to handle varying database dialects.
*
@ -62,6 +62,11 @@ class AwlDatabase extends AwlDBDialect {
*/
protected $txnstate = 0;
/**
* Holds whether we are translating all statements.
*/
protected $translate_all = false;
/**#@-*/
/**
@ -70,6 +75,9 @@ class AwlDatabase extends AwlDBDialect {
* @param array $driver_options PDO driver options to the prepare statement, commonly to do with cursors
*/
function prepare( $statement, $driver_options = array() ) {
if ( isset($this->translate_all) && $this->translate_all ) {
$statement = $this->TranslateSQL( $statement );
}
return $this->db->prepare( $statement, $driver_options );
}
@ -139,7 +147,9 @@ class AwlDatabase extends AwlDBDialect {
* Operates identically to AwlDatabase::Prepare, except that $this->Translate() will be called on the query
* before any processing.
*/
function PrepareTranslated() {
function PrepareTranslated( $statement, $driver_options = array() ) {
$statement = $this->TranslateSQL( $statement );
return $this->prepare( $statement, $driver_options );
}
@ -148,6 +158,8 @@ class AwlDatabase extends AwlDBDialect {
* as if PrepareTranslated() had been called.
*/
function TranslateAll( $onoff_boolean ) {
$this->translate_all = $onoff_boolean;
return $onoff_boolean;
}

View File

@ -1,7 +1,7 @@
<?php
/**
* @package awl
* @subpackage AWLDB
* @subpackage AwlDatabase
* @author Andrew McMillan <andrew@morphoss.com>
* @copyright Morphoss Ltd
* @license http://gnu.org/copyleft/gpl.html GNU GPL v3 or later

39
inc/AwlUpgrader.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* @package awl
* @subpackage AwlDatabase
* @author Andrew McMillan <andrew@morphoss.com>
* @copyright Morphoss Ltd
* @license http://www.gnu.org/licenses/lgpl-3.0.txt GNU LGPL version 3 or later
* @compatibility Requires PHP 5.1 or later
*/
require_once('AwlQuery.php');
/**
* Database upgrader class and associated functions
*
* This subpackage provides some functions that are useful around database
* schema creation and changes.
*
*/
/**
* The AwlUpgrader Class.
*
* This class updates an Awl database to a newer schema version.
*
*
* @package awl
*/
class AwlUpgrader
{
/**
* Constructor
* @return The AwlUpgrader object
*/
function __construct() {
return $this;
}
}