2012-04-18 15:53:06 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
2012-04-20 13:17:39 -04:00
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren
|
2012-04-18 15:53:06 -04:00
|
|
|
* @copyright Copyright (c) 2012
|
|
|
|
* @link https://github.com/aviat4ion/Query
|
2012-04-20 13:17:39 -04:00
|
|
|
* @license http://philsturgeon.co.uk/code/dbad-license
|
2012-04-18 15:53:06 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract class defining database / table creation methods
|
2012-04-20 13:17:39 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @subpackage Query
|
2012-04-18 15:53:06 -04:00
|
|
|
*/
|
2012-04-27 16:18:59 -04:00
|
|
|
abstract class DB_Util extends StdClass {
|
2012-04-18 15:53:06 -04:00
|
|
|
|
2012-04-19 11:42:50 -04:00
|
|
|
/**
|
|
|
|
* Reference to the current connection object
|
|
|
|
*/
|
2012-04-18 15:53:06 -04:00
|
|
|
private $conn;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save a reference to the connection object for later use
|
2012-04-19 11:42:50 -04:00
|
|
|
*
|
|
|
|
* @param object &$conn
|
2012-04-18 15:53:06 -04:00
|
|
|
*/
|
|
|
|
public function __construct(&$conn)
|
|
|
|
{
|
|
|
|
$this->conn =& $conn;
|
|
|
|
}
|
|
|
|
|
2012-04-18 16:28:12 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable calling driver methods
|
|
|
|
*
|
|
|
|
* @param string $method
|
|
|
|
* @param array $args
|
|
|
|
*/
|
|
|
|
public function __call($method, $args)
|
|
|
|
{
|
|
|
|
if (method_exists($this->conn, $method))
|
|
|
|
{
|
|
|
|
return call_user_func_array(array($this->conn, $method), $args);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-18 15:53:06 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ! Abstract Methods
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get database-specific sql to create a new table
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @param string $name
|
|
|
|
* @param array $columns
|
|
|
|
* @param array $constraints
|
|
|
|
* @param array $indexes
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function create_table($name, $columns, array $constraints=array(), array $indexes=array());
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get database-specific sql to drop a table
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @param string $name
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function delete_table($name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an SQL file with the database table structure
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function backup_structure();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an SQL file with the database data as insert statements
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function backup_data();
|
|
|
|
|
|
|
|
}
|