Permalink
Browse files

fixed virtual destructors, a minor typo in test, bump version number …

…for release

git-svn-id: http://svn.php.net/repository/pear/packages/DBA/trunk@96921 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent bedc44d commit 09ca93b5ebf09ef36abb4211e9437f79ddc8e77a Brent Cook committed Sep 26, 2002
Showing with 60 additions and 43 deletions.
  1. +10 −1 DBA.php
  2. +1 −1 DBA/Compatibility.php
  3. +3 −1 DBA/Driver/Builtin.php
  4. +5 −5 DBA/Driver/File.php
  5. +8 −4 package.xml
  6. +33 −31 tests/test_file_driver.php
View
11 DBA.php
@@ -30,13 +30,22 @@
* dbm engine for installations where dba support is not included in PHP.
*
* @author Brent Cook <busterb@mail.utexas.edu>
- * @version 0.9.2
+ * @version 0.9.3
* @access public
* @package DBA
*/
class DBA extends PEAR
{
/**
+ * Default constructor
+ */
+ function DBA()
+ {
+ // call the base constructor
+ $this->PEAR();
+ }
+
+ /**
* Creates a new DBA object
*
* @static
View
@@ -29,7 +29,7 @@
* work.
*
* @author Brent Cook <busterb@mail.utexas.edu>
- * @version 0.9.2
+ * @version 0.9.3
* @access public
* @package DBA
* @see PHP dba Documentation
View
@@ -32,7 +32,7 @@
* driver due to its lack of writes. DB2 currently segfaults with PHP-CVS.
*
* @author Brent Cook <busterb@mail.utexas.edu>
- * @version 0.9.2
+ * @version 0.9.3
* @access public
* @package DBA
*/
@@ -79,6 +79,8 @@ class DBA_Driver_Builtin extends DBA
*/
function DBA_Driver_Builtin($driver = 'gdbm')
{
+ // call the base constructor
+ $this->DBA();
$this->_driver = $driver;
}
// }}}
View
@@ -72,7 +72,7 @@
* The sync function calls fflush on the data and index files.
*
* @author Brent Cook
- * @version 0.9.2
+ * @version 0.9.3
* @access public
* @package DBA
*/
@@ -108,22 +108,24 @@ class DBA_Driver_File extends DBA
* @access private
*/
var $_readable;
- // }}}
/**
* Determines if the driver should use an index file
* @access private
*/
var $_indexed;
+ // }}}
- // {{{ DBA_Driver_Builtin($indexed = true)
+ // {{{ DBA_Driver_File($indexed = true)
/* Constructor
*
* @access public
* @param string $driver dba driver to use
*/
function DBA_Driver_File($indexed = true)
{
+ // call the base constructor
+ $this->DBA();
$this->_indexed = true;
}
// }}}
@@ -242,8 +244,6 @@ function close()
$this->_writable = false;
fclose($this->_idxFP);
fclose($this->_datFP);
- } else {
- return $this->raiseError('No database was open');
}
}
// }}}
View
@@ -20,13 +20,17 @@ DBA is a wrapper for the php DBA functions. It includes a file-based emulator an
<release>
<license>LGPL</license>
- <version>0.9.2</version>
- <date>2002-09-25</date>
+ <version>0.9.3</version>
+ <date>2002-09-26</date>
<state>beta</state>
<notes>
-This release fixes a bug in the firstkey() function of the builtin drivers (gdbm, db3) and adds the missing size() function.
+This release updates the driver constructors so that they call their base class's constructors. This makes PEAR's virtual destructor system function properly.
-Note that many of the pieces that were included with the earlier developer releases, such as the table manager and SQL parser, have been split into separate packages to be released again soon.
+NOTE: The file driver appears to work incorrectly with the latest PHP CVS. I am
+currently investigating the issue. For now, either use CVS from a few weeks
+ago, or PHP up to 4.2.3.
+
+Many of the functions that were included with the earlier developer releases, such as the table manager and SQL parser, have been split into separate packages to be released soon.
</notes>
<filelist>
<dir name="/" baseinstalldir="/">
View
@@ -29,44 +29,46 @@
include 'PEAR.php';
include 'DBA/Driver/File.php';
-$testDataArray = array ('1', '22', '333', '4444', '55555', '6666666', '7777777', '88888888', '999999999');
+$testDataArray = array ('1', '22', '333', '4444', '55555', '666666',
+ '7777777', '88888888', '999999999');
-$maxDataIndex = sizeof ($testDataArray)-1;
+$maxDataIndex = sizeof($testDataArray)-1;
$testDB =& new DBA_Driver_File();
-if (PEAR::isError($error=$testDB->open('file_test', 'c')))
-{
+if (PEAR::isError($error=$testDB->open('file_test', 'c'))) {
echo $error->getMessage()."\n";
-} else {
- for ($i=0; $i<5000; ++$i) {
- $testKey = rand (0, 99);
- $testData = $testDataArray[rand(0, 8)];
- switch (rand(0, 3)) {
- case 0:
- if (!$testDB->exists($testKey)) {
- $result = $testDB->insert($testKey, $testData);
- }
- break;
- case 1:
- if ($testDB->exists($testKey)) {
- $result = $testDB->remove($testKey);
- }
- break;
- case 2:
- $result = $testDB->replace($testKey, $testData);
- break;
- case 3:
- if ($testDB->exists($testKey)) {
- $result = $testDB->fetch($testKey);
- }
- }
- if (PEAR::isError($result)) {
- echo $result->getMessage()."\n";
- }
+ exit;
+}
+
+// main testing loop
+for ($i=0; $i<5000; ++$i) {
+ $testKey = rand (0, 200);
+ $testData = $testDataArray[rand(0, 8)];
+ switch (rand(0, 3)) {
+ case 0:
+ if (!$testDB->exists($testKey)) {
+ $result = $testDB->insert($testKey, $testData);
+ }
+ break;
+ case 1:
+ if ($testDB->exists($testKey)) {
+ $result = $testDB->remove($testKey);
+ }
+ break;
+ case 2:
+ $result = $testDB->replace($testKey, $testData);
+ break;
+ case 3:
+ if ($testDB->exists($testKey)) {
+ $result = $testDB->fetch($testKey);
+ }
+ }
+ if (PEAR::isError($result)) {
+ echo $result->getMessage()."\n";
}
- $testDB->close();
}
+$testDB->close();
$testDB->open('file_test', 'r');
$key = $testDB->firstkey();

0 comments on commit 09ca93b

Please sign in to comment.