Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.6

Bug #7287 create is triggered while in 'alter' mode
Submitted: 2006-04-04 09:08 UTC
From: vdb at mail dot ru Assigned: wiesemann
Status: Closed Package: DB_Table (version CVS)
PHP Version: 4.4.0 OS: linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-04-04 09:08 UTC] vdb at mail dot ru (vdb)
Description: ------------ Somehow create() is triggered while in 'alter' mode causing data inserts, defined inside create() each time class instance is created. This is unexpected behaviour. I think only 'drop' mode should call create(). Test script: --------------- class my_table extends DB_Table { function create($flag) { // call the parent create() first $result = parent::create($flag); // was the table created? if (PEAR::isError($result) || ! $result) { // table not created return $result; } else { // table created successfully; insert some rows... $cols = array( 'id' => 1, 'name' => 'name', ); $res = $this->insert($cols); if (PEAR::isError($res)) { return PEAR::throwError($res->getMessage()); } return $res; } } // class my_table Expected result: ---------------- I think only 'drop' mode should call create(). Actual result: -------------- Unwanted data inserts in 'alter' creation mode.

Comments

 [2006-04-04 21:19 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-04-07 16:55 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-04-07 18:19 UTC] vdb at mail dot ru
Tank you, Mark. Though I've found a few copy&past errors. Suggested patch: --- Table.php.new 2006-04-07 20:48:22.000000000 +0400 +++ Table.php 2006-04-07 21:56:00.000000000 +0400 @@ -754,20 +754,20 @@ // check whether the chosen mode is supported list($phptype,) = DB_Table::getPHPTypeAndDBSyntax($this->db); - $mode_supported = DB_Table::modeSupported($flag, $phptype); + $mode_supported = DB_Table::modeSupported($create, $phptype); if (PEAR::isError($mode_supported)) { return $mode_supported; } if (!$mode_supported) { return $this->throwError( DB_TABLE_ERR_CREATE_PHPTYPE, - "('$flag', '$phptype')" + "('$create', '$phptype')" ); } include_once 'DB/Table/Manager.php'; - switch ($flag) { + switch ($create) { case 'alter': $result = $this->alter(); @@ -775,7 +775,7 @@ case 'drop': case 'safe': - $result = $this->create($flag); + $result = $this->create($create); break; case 'verify': @@ -863,7 +863,7 @@ // unknown creation mode return $this->throwError( DB_TABLE_ERR_CREATE_FLAG, - "('$flag')" + "('$mode')" ); } }
 [2006-04-07 20:09 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!