Split db_pdo and db_sql classes

This commit is contained in:
Timothy Warren 2012-04-09 14:26:55 -04:00
parent 9614482341
commit 6b722608b7
4 changed files with 75 additions and 66 deletions

View File

@ -295,52 +295,4 @@ abstract class DB_PDO extends PDO {
*/ */
abstract public function backup_data(); abstract public function backup_data();
} }
// -------------------------------------------------------------------------
/**
* Abstract parent for database manipulation subclasses
*/
abstract class DB_SQL {
/**
* 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);
/**
* Get database specific sql for limit clause
*
* @abstract
* @param string $sql
* @param int $limiit
* @param int $offset
* @return string
*/
abstract public function limit($sql, $limit, $offset=FALSE);
/**
* Get the sql for random ordering
*
* @abstract
* @return string
*/
abstract public function random();
}
// End of db_pdo.php // End of db_pdo.php

60
sys/db/db_sql.php Normal file
View File

@ -0,0 +1,60 @@
<?php
/**
* OpenSQLManager
*
* Free Database manager for Open Source Databases
*
* @author Timothy J. Warren
* @copyright Copyright (c) 2012
* @link https://github.com/aviat4ion/OpenSQLManager
* @license http://philsturgeon.co.uk/code/dbad-license
*/
// --------------------------------------------------------------------------
/**
* Abstract parent for database manipulation subclasses
*/
abstract class DB_SQL {
/**
* 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);
/**
* Get database specific sql for limit clause
*
* @abstract
* @param string $sql
* @param int $limiit
* @param int $offset
* @return string
*/
abstract public function limit($sql, $limit, $offset=FALSE);
/**
* Get the sql for random ordering
*
* @abstract
* @return string
*/
abstract public function random();
}
// End of db_sql.php

View File

@ -55,19 +55,6 @@ class Data_Grid extends GtkTreeView {
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
/**
* Set the value of the cell at the provided coordinate array
*
* @param array $coord
* @param mixed $val
*/
public function set(array $coord, $val)
{
// @todo implement
}
// --------------------------------------------------------------------------
/** /**
* Empty the model * Empty the model
*/ */

View File

@ -19,6 +19,19 @@ define('TEST_DIR', dirname(__FILE__));
define('BASE_DIR', str_replace(basename(TEST_DIR), '', TEST_DIR).'/sys/'); define('BASE_DIR', str_replace(basename(TEST_DIR), '', TEST_DIR).'/sys/');
define('DS', DIRECTORY_SEPARATOR); define('DS', DIRECTORY_SEPARATOR);
// --------------------------------------------------------------------------
/**
* Alias for require_once for array_map
*
* @param string $path
* @return void
*/
function do_include($path)
{
require_once($path);
}
// Include simpletest // Include simpletest
// it has to be set in your php path, or put in the tests folder // it has to be set in your php path, or put in the tests folder
@ -26,7 +39,6 @@ require_once('simpletest/autorun.php');
// Require base testing classes // Require base testing classes
require_once(TEST_DIR.'/parent.php'); require_once(TEST_DIR.'/parent.php');
require_once(TEST_DIR.'/settings.php');
// Bulk loading wrapper workaround for PHP < 5.4 // Bulk loading wrapper workaround for PHP < 5.4
function do_include($path) function do_include($path)
@ -38,10 +50,8 @@ function do_include($path)
require_once("core.php"); require_once("core.php");
// Include required methods // Include required methods
require_once(BASE_DIR.'common/functions.php'); array_map('do_include', glob(BASE_DIR . 'common/*.php'));
require_once(BASE_DIR.'common/settings.php'); array_map('do_include', glob(BASE_DIR . 'db/*.php'));
require_once(BASE_DIR.'db/db_pdo.php');
require_once(BASE_DIR.'db/query_builder.php');
// Include db tests // Include db tests