Added delete_table method to database manipulation classes

This commit is contained in:
Timothy Warren 2012-02-07 20:50:25 -05:00
parent dc6c9bf141
commit 48c2501f41
6 changed files with 62 additions and 0 deletions

View File

@ -160,5 +160,14 @@ abstract class db_manip {
* @return string
*/
abstract function create_table($name, $columns, $constraints=array(), $indexes=array());
/**
* Get database-specific sql to drop a table
*
* @param string $name
*
* @return string
*/
abstract function delete_table($name);
}
// End of db_pdo.php

View File

@ -23,6 +23,17 @@ class firebird_manip extends db_manip{
{
$sql = "CREATE TABLE {$name}";
}
/**
* Drop the selected table
*
* @param string $name
* @return string
*/
function delete_table($name)
{
return "DELETE TABLE {$name}";
}
}
//End of firebird_manip.php

View File

@ -17,9 +17,30 @@
*/
class MySQL_manip extends db_manip{
/**
* Convienience function for creating a new MySQL table
*
* @param [type] $name [description]
* @param [type] $columns [description]
* @param array $constraints=array() [description]
* @param array $indexes=array() [description]
*
* @return [type]
*/
function create_table($name, $columns, $constraints=array(), $indexes=array())
{
//TODO: implement
}
/**
* Convience function for droping a MySQL table
*
* @param string $name
* @return string
*/
function delete_table($name)
{
return "DROP TABLE `{$name}`";
}
}
//End of mysql_manip.php

View File

@ -24,5 +24,10 @@ class ODBC_manip extends db_manip {
//ODBC can't know how to create a table
return FALSE;
}
function delete_table($name)
{
return "DROP TABLE {$name}";
}
}
// End of odbc_manip.php

View File

@ -24,5 +24,10 @@ class pgSQL_manip extends db_manip {
//TODO: implement
}
function delete_table($name)
{
return 'DROP TABLE "'.$name.'"';
}
}
//End of pgsql_manip.php

View File

@ -74,6 +74,17 @@ class SQLite_manip extends db_manip {
return $sql;
}
/**
* SQL to drop the specified table
*
* @param string $name
* @return string
*/
function delete_table($name)
{
return "DROP TABLE IF EXISTS {$table}";
}
/**
* Create an sqlite database file
*