cvs: pear /DB_Table/DB Table.php /DB_Table/DB/Table Manager.php

From: Date: Tue, 16 Nov 2004 17:32:49 +0000
Subject: cvs: pear /DB_Table/DB Table.php /DB_Table/DB/Table Manager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-26014@lists.php.net to get a copy of this message
pmjones Tue Nov 16 12:32:49 2004 EDT Modified files: /pear/DB_Table/DB Table.php /pear/DB_Table/DB/Table Manager.php Log: added string-length checks (30 char limit for Oracle), shortened index naming convention to "_idx" suffix instead of "_index", and related error messages http://cvs.php.net/diff.php/pear/DB_Table/DB/Table.php?r1=1.15&r2=1.16&ty=u Index: pear/DB_Table/DB/Table.php diff -u pear/DB_Table/DB/Table.php:1.15 pear/DB_Table/DB/Table.php:1.16 --- pear/DB_Table/DB/Table.php:1.15 Tue Nov 16 11:37:18 2004 +++ pear/DB_Table/DB/Table.php Tue Nov 16 12:32:47 2004 @@ -119,6 +119,12 @@ define('DB_TABLE_ERR_IDX_COL_CLOB', -20); +define('DB_TABLE_ERR_DECLARE_STRLEN', -21); + +define('DB_TABLE_ERR_IDX_STRLEN', -21); + + + /** * The PEAR class for errors */ @@ -256,7 +262,9 @@ DB_TABLE_ERR_DECLARE_COLNAME => 'Column name not valid', DB_TABLE_ERR_DECLARE_IDXNAME => 'Index name not valid', DB_TABLE_ERR_DECLARE_TYPE => 'Column type not valid', - DB_TABLE_ERR_IDX_COL_CLOB => 'CLOB column not allowed for index' + DB_TABLE_ERR_IDX_COL_CLOB => 'CLOB column not allowed for index', + DB_TABLE_ERR_DECLARE_STRLEN => 'Column name too long, 30 char max', + DB_TABLE_ERR_IDX_STRLEN => 'Index name too long, 30 char max' ); } @@ -271,7 +279,7 @@ * and automated creation of QuickForm elemnts based on the column * definitions. * -* $Id: Table.php,v 1.15 2004/11/16 16:37:18 pmjones Exp $ +* $Id: Table.php,v 1.16 2004/11/16 17:32:47 pmjones Exp $ * * @author Paul M. Jones <pmjones@ciaweb.net> * http://cvs.php.net/diff.php/pear/DB_Table/DB/Table/Manager.php?r1=1.4&r2=1.5&ty=u Index: pear/DB_Table/DB/Table/Manager.php diff -u pear/DB_Table/DB/Table/Manager.php:1.4 pear/DB_Table/DB/Table/Manager.php:1.5 --- pear/DB_Table/DB/Table/Manager.php:1.4 Sat Jul 10 11:08:33 2004 +++ pear/DB_Table/DB/Table/Manager.php Tue Nov 16 12:32:49 2004 @@ -10,7 +10,7 @@ * DB_Table_Manager provides database automated table creation * facilities (and eventually table alteration as well). * -* $Id: Manager.php,v 1.4 2004/07/10 15:08:33 pmjones Exp $ +* $Id: Manager.php,v 1.5 2004/11/16 17:32:49 pmjones Exp $ * * @author Paul M. Jones <pmjones@ciaweb.net> * @@ -75,6 +75,15 @@ ); } + // column must be no longer than 30 chars + if (strlen($colname) > 30) { + return DB_Table::throwError( + DB_TABLE_ERR_DECLARE_STRLEN, + "('$colname')" + ); + } + + // prepare variables $type = (isset($val['type'])) ? $val['type'] : null; $size = (isset($val['size'])) ? $val['size'] : null; @@ -160,12 +169,20 @@ // string of column names $colstring = implode(', ', $cols); - // we prefix all index names with the table name, - // and suffix all index names with '_index'. this + // we prefix all index names with the table name. this // is to soothe PostgreSQL, which demands that index - // names not collide, even when they indexes are on - // different tables. - $newIdxName = $table . '_' . $idxname . '_index'; + // names not collide, even when the indexes are on + // different tables. always suffix with '_idx'. + $newIdxName = $table . '_' . $idxname . '_idx'; + + // now check the length; must be under 30 chars to + // soothe Oracle. + if (strlen($newIdxName) > 30) { + return DB_Table::throwError( + DB_TABLE_ERR_IDX_STRLEN, + "'$idxname' ('$newIdxName')" + ); + } // create index entry if ($type == 'unique') {

« previous php.pear.cvs (#26014) next »