2012-04-10 14:06:34 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
|
|
|
* Free Query Builder / Database Abstraction Layer
|
|
|
|
*
|
2012-04-20 13:17:39 -04:00
|
|
|
* @author Timothy J. Warren
|
2012-04-10 14:06:34 -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
|
|
|
|
* @package Query
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract parent for database manipulation subclasses
|
2012-04-20 13:17:39 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @subpackage Query
|
2012-04-10 14:06:34 -04:00
|
|
|
*/
|
2012-04-27 16:18:59 -04:00
|
|
|
abstract class DB_SQL extends StdClass {
|
2012-04-10 14:06:34 -04:00
|
|
|
|
2012-04-13 11:53:11 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ! Methods to override
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the max keyword sql
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function max()
|
|
|
|
{
|
|
|
|
return ' MAX';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the min keyword sql
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function min()
|
|
|
|
{
|
|
|
|
return ' MIN';
|
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the 'distinct' keyword
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function distinct()
|
|
|
|
{
|
2012-04-13 16:50:05 -04:00
|
|
|
return ' DISTINCT ';
|
2012-04-13 11:53:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the 'average' keyword
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function avg()
|
|
|
|
{
|
|
|
|
return ' AVG';
|
|
|
|
}
|
|
|
|
|
2012-04-13 12:49:13 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the 'sum' keyword
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function sum()
|
|
|
|
{
|
|
|
|
return ' SUM';
|
|
|
|
}
|
|
|
|
|
2012-04-13 11:53:11 -04:00
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
// ! Abstract Methods
|
|
|
|
// --------------------------------------------------------------------------
|
|
|
|
|
2012-04-10 14:06:34 -04:00
|
|
|
/**
|
|
|
|
* Get database specific sql for limit clause
|
|
|
|
*
|
|
|
|
* @abstract
|
|
|
|
* @param string $sql
|
2012-04-19 11:42:50 -04:00
|
|
|
* @param int $limit
|
2012-04-10 14:06:34 -04:00
|
|
|
* @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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list other databases
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function db_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list tables
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function table_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list system tables
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function system_table_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list views
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function view_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns sql to list triggers
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function trigger_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list functions
|
|
|
|
*
|
|
|
|
* @return FALSE
|
|
|
|
*/
|
|
|
|
abstract public function function_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list stored procedures
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function procedure_list();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return sql to list sequences
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
abstract public function sequence_list();
|
|
|
|
}
|
|
|
|
// End of db_sql.php
|