cvs: pear /DB_Table package2.xml /DB_Table/DB Table.php
| From: | Mark Wiesemann | Date: | Fri, 28 Mar 2008 17:58:17 +0000 |
| Subject: | cvs: pear /DB_Table package2.xml /DB_Table/DB Table.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-51714@lists.php.net to get a copy of this message | ||
wiesemann Fri Mar 28 17:58:17 2008 UTC
Modified files:
/pear/DB_Table package2.xml
/pear/DB_Table/DB Table.php
Log:
- Request #13267: constructor's $table parameter is now optional; this change
allows to set a fixed table name via the $table property in the DB_Table
subclass
- error handling fix: $_primary_subclass property needs to be defined at the beginning of the
constructor
- update changelog
http://cvs.php.net/viewvc.cgi/pear/DB_Table/package2.xml?r1=1.36&r2=1.37&diff_format=u
Index: pear/DB_Table/package2.xml
diff -u pear/DB_Table/package2.xml:1.36 pear/DB_Table/package2.xml:1.37
--- pear/DB_Table/package2.xml:1.36 Thu Dec 13 16:52:13 2007
+++ pear/DB_Table/package2.xml Fri Mar 28 17:58:17 2008
@@ -43,7 +43,7 @@
<time>12:00:00</time>
<version>
<release>1.5.1</release>
- <api>1.5.0</api>
+ <api>1.5.1</api>
</version>
<stability>
<release>stable</release>
@@ -64,6 +64,9 @@
corrections (missing error return call, change MDB2's portability mode only
temporarily)
(thanks to Carsten Wiedmann for the patch)
+- Request #13267: constructor's $table parameter is now optional; this change
+ allows to set a fixed table name via the $table property in the DB_Table
+ subclass
</notes>
<contents>
<dir name="/">
http://cvs.php.net/viewvc.cgi/pear/DB_Table/DB/Table.php?r1=1.88&r2=1.89&diff_format=u
Index: pear/DB_Table/DB/Table.php
diff -u pear/DB_Table/DB/Table.php:1.88 pear/DB_Table/DB/Table.php:1.89
--- pear/DB_Table/DB/Table.php:1.88 Thu Dec 13 16:52:14 2007
+++ pear/DB_Table/DB/Table.php Fri Mar 28 17:58:17 2008
@@ -48,7 +48,7 @@
* @author David C. Morse <morse@php.net>
* @author Mark Wiesemann <wiesemann@php.net>
* @license http://opensource.org/licenses/bsd-license.php
New BSD License
- * @version CVS: $Id: Table.php,v 1.88 2007/12/13 16:52:14 wiesemann Exp $
+ * @version CVS: $Id: Table.php,v 1.89 2008/03/28 17:58:17 wiesemann Exp $
* @link http://pear.php.net/package/DB_Table
*/
@@ -275,6 +275,12 @@
define('DB_TABLE_ERR_AUTO_INC_COL', -37);
/**
+ * Error code at instantiation time when both the $table parameter
+ * and the $table class property are missing.
+ */
+define('DB_TABLE_ERR_TABLE_NAME_MISSING', -38);
+
+/**
* The DB_Table_Base parent class
*/
require_once 'DB/Table/Base.php';
@@ -482,7 +488,8 @@
DB_TABLE_ERR_DECLARE_PRIM_SQLITE => 'SQLite does not support primary keys',
DB_TABLE_ERR_ALTER_TABLE_IMPOS => 'Alter table failed: changing the field type not
possible',
DB_TABLE_ERR_ALTER_INDEX_IMPOS => 'Alter table failed: changing the index/constraint
not possible',
- DB_TABLE_ERR_AUTO_INC_COL => 'Illegal auto-increment column definition'
+ DB_TABLE_ERR_AUTO_INC_COL => 'Illegal auto-increment column definition',
+ DB_TABLE_ERR_TABLE_NAME_MISSING => 'Table name missing in constructor and class'
);
// merge default and user-defined error messages
@@ -632,8 +639,11 @@
* @return object DB_Table
* @access public
*/
- function DB_Table(&$db, $table, $create = false)
+ function DB_Table(&$db, $table = null, $create = false)
{
+ // Identify the class for error handling by parent class
+ $this->_primary_subclass = 'DB_TABLE';
+
// is the first argument a DB/MDB2 object?
$this->backend = null;
if (is_subclass_of($db, 'db_common')) {
@@ -649,10 +659,15 @@
// set the class properties
$this->db =& $db;
- $this->table = $table;
-
- // Identify the class for error handling by parent class
- $this->_primary_subclass = 'DB_TABLE';
+ if (is_null($table)) {
+ // $table parameter not given => check $table class property
+ if (is_null($this->table)) {
+ $this->error =& DB_Table::throwError(DB_TABLE_ERR_TABLE_NAME_MISSING);
+ return;
+ }
+ } else {
+ $this->table = $table;
+ }
// is the RDBMS supported?
$phptype = $db->phptype;