Note: this list is kept only as a demonstration for CVSNotice. For the latest CVS notices, see the Xaraya and Postnuke sites
View Statistics - Next Notice - Previous NoticeDirectory filter : [ all ] / postnuke_official / html / includes [ view in CVS ]
Date | Directory [filter] | File(s) [view] | Author [filter] |
13 Aug 2002 08:52:51 | postnuke_official/html/includes | pnTableDDL.php,1.6,1.7 | Marco Canini |
Added exceptions. |
Update of /home/cvsroot/postnuke_official/html/includes In directory ns7.hostnuke.net:/tmp/cvs-serv2439 Modified Files: pnTableDDL.php Log Message: Added exceptions. Index: pnTableDDL.php =================================================================== RCS file: /home/cvsroot/postnuke_official/html/includes/pnTableDDL.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pnTableDDL.php 11 Aug 2002 00:12:07 -0000 1.6 --- pnTableDDL.php 13 Aug 2002 08:52:49 -0000 1.7 *************** *** 53,57 **** // perform validations on input arguments ! if (empty($database_name)) return FALSE; if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); --- 53,62 ---- // perform validations on input arguments ! if (empty($database_name)) { ! $msg = pnML('Empty database_name.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); *************** *** 65,73 **** // Other DBs go here default: ! $sql = FALSE; } return $sql; } /** * Alter database table --- 70,82 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql; } + /** * Alter database table *************** *** 89,96 **** { // perform validations on input arguments ! if (empty($args)) return FALSE; ! if (!is_array($args)) return FALSE; ! if (empty($args['table']) || empty($args['command'])) return FALSE; ! if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); --- 98,109 ---- { // perform validations on input arguments ! if (empty($args) || !is_array($args) || ! empty($args['table']) || empty($args['command'])) { ! $msg = pnML('Empty or invalid args (table and command keys must be set).'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); *************** *** 106,167 **** // Other DBs go here default: ! $sql = FALSE; } return $sql; } - function pnMySQLAlterTable($args) - { - switch ($args['command']) { - case 'add': - if (empty($args['field'])) return FALSE; - $sql = 'ALTER TABLE '.$args['table'].' ADD '; - $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args)); - if ($args['first'] == TRUE) { - $sql .= ' FIRST'; - } elseif (!empty($args['after_field'])) { - $sql .= ' AFTER '.$args['after_field']; - } - break; - // Disabled July 12, 2002 by Gary Mitchell - not supported by postgres - // case 'modify': - // if (empty($args['field'])) return FALSE; - // $sql = 'ALTER TABLE '.$args['table'].' CHANGE '; - // $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args)); - // break; - // Disabled July 12, 2002 by Gary Mitchell - not supported by postgres - // case 'drop': - // if (empty($args['field'])) return FALSE; - // $sql = 'ALTER TABLE '.$args['table'].' DROP COLUMN '.$args['field']; - // break; - case 'rename': - if (empty($args['new_name'])) return FALSE; - $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name']; - break; - default: - $sql = FALSE; - } - return $sql; - } - - function pnPostgresAlterTable($args) - { - switch ($args['command']) { - case 'add': - if (empty($args['field'])) return FALSE; - $sql = 'ALTER TABLE '.$args['table'].' ADD '; - $sql .= join(' ',pnPostgresColumnDefinition ($args['field'],$args)); - break; - case 'rename': - if (empty($args['new_name'])) return FALSE; - $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name']; - break; - default: - $sql = FALSE; - } - return $sql; - } - - /** * generate the SQL to create a table --- 119,130 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql; } /** * generate the SQL to create a table *************** *** 177,182 **** { // perform validations on input arguments ! if (empty($table)) return FALSE; ! if (!is_array($fields)) return FALSE; if (empty($dbtype)) { --- 140,155 ---- { // perform validations on input arguments ! if (empty($table)) { ! $msg = pnML('Empty table.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! if (!is_array($fields)) { ! $msg = pnML('Not array fields.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } if (empty($dbtype)) { *************** *** 193,197 **** // Other DBs go here default: ! $sql_statement = FALSE; } return $sql_statement; --- 166,173 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql_statement; *************** *** 212,217 **** { // perform validations on input arguments ! if (empty($table)) return FALSE; ! if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); --- 188,197 ---- { // perform validations on input arguments ! if (empty($table)) { ! $msg = pnML('Empty table.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); *************** *** 225,229 **** // Other DBs go here default: ! $sql = FALSE; } return $sql; --- 205,212 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql; *************** *** 242,250 **** // perform validations on input arguments ! if (empty($table)) return FALSE; ! if (!is_array($index)) return FALSE; ! if (!is_array($index['fields'])) return FALSE; ! if (empty($index['name']) || empty($index['fields'])) return FALSE; ! if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); --- 225,240 ---- // perform validations on input arguments ! if (empty($table)) { ! $msg = pnML('Empty table.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! if (!is_array($index) || !is_array($index['fields']) || empty($index['name'])) { ! $msg = pnML('Invalid index (must be an array, fields key must be an array, name key must be set).'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); *************** *** 266,270 **** // Other DBs go here default: ! $sql = FALSE; } return $sql; --- 256,263 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql; *************** *** 274,282 **** { // perform validations on input arguments ! if (empty($table)) return FALSE; ! if (!is_array($index)) return FALSE; ! if (!is_array($index['fields'])) return FALSE; ! if (empty($index['name']) || empty($index['fields'])) return FALSE; ! if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); --- 267,282 ---- { // perform validations on input arguments ! if (empty($table)) { ! $msg = pnML('Empty table.'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } ! if (!is_array($index) || !is_array($index['fields']) || empty($index['name'])) { ! $msg = pnML('Invalid index (must be an array, fields key must be an array, name key must be set).'); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; ! } if (empty($dbtype)) { $dbtype = pnConfigGetVar('dbtype'); *************** *** 296,300 **** // Other DBs go here default: ! $sql = FALSE; } return $sql; --- 296,303 ---- // Other DBs go here default: ! $msg = pnML('Unknown database type: \'#(1)\'.', $dbtype); ! pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', ! new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); ! return; } return $sql; *************** *** 305,309 **** --- 308,407 ---- /** + * @access private + */ + function pnMySQLAlterTable($args) + { + switch ($args['command']) { + case 'add': + if (empty($args['field'])) { + $msg = pnML('field key must be set.'); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + $sql = 'ALTER TABLE '.$args['table'].' ADD '; + $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args)); + if ($args['first'] == TRUE) { + $sql .= ' FIRST'; + } elseif (!empty($args['after_field'])) { + $sql .= ' AFTER '.$args['after_field']; + } + break; + // Disabled July 12, 2002 by Gary Mitchell - not supported by postgres + // case 'modify': + // if (empty($args['field'])) { + // $msg = pnML('field key must be set.'); + // pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + // new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + // return; + // } + // $sql = 'ALTER TABLE '.$args['table'].' CHANGE '; + // $sql .= join(' ',pnMySQLColumnDefinition ($args['field'],$args)); + // break; + // Disabled July 12, 2002 by Gary Mitchell - not supported by postgres + // case 'drop': + // if (empty($args['field'])) { + // $msg = pnML('field key must be set.'); + // pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + // new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + // return; + // } + // $sql = 'ALTER TABLE '.$args['table'].' DROP COLUMN '.$args['field']; + // break; + case 'rename': + if (empty($args['new_name'])) { + $msg = pnML('new_name key must be set.'); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name']; + break; + default: + $msg = pnML('Unknown command: \'#(1)\'.', $args['command']); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + return $sql; + } + + /** + * @access private + */ + function pnPostgresAlterTable($args) + { + switch ($args['command']) { + case 'add': + if (empty($args['field'])) { + $msg = pnML('field key must be set.'); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + $sql = 'ALTER TABLE '.$args['table'].' ADD '; + $sql .= join(' ',pnPostgresColumnDefinition ($args['field'],$args)); + break; + case 'rename': + if (empty($args['new_name'])) { + $msg = pnML('new_name key must be set.'); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + $sql = 'ALTER TABLE '.$args['table'].' RENAME TO '.$args['new_name']; + break; + default: + $msg = pnML('Unknown command: \'#(1)\'.', $args['command']); + pnExceptionSet(PN_SYSTEM_EXCEPTION, 'BAD_PARAM', + new SystemException(__FILE__.'('.__LINE__.'): '.$msg)); + return; + } + return $sql; + } + + /** * Private Function to generate the MySQL to create a table + * @access private * @param table the physical table name * @param fields an array containing the fields to create *************** *** 324,327 **** --- 422,428 ---- } + /** + * @access private + */ function pnMySQLColumnDefinition ($field_name,$parameters) { *************** *** 544,547 **** --- 645,651 ---- } + /** + * @access private + */ function pnPostgresColumnDefinition ($field_name,$parameters) {
View Statistics - Next Notice - Previous Notice
Visit Developer Site - Browse CVS Repository |
Syndicate via backend.rss (max. once per hour please) | Powered by CVSNotice 0.1.3 |