Skip to content

Commit

Permalink
fixed virtual destructors, a minor typo in test, bump version number …
Browse files Browse the repository at this point in the history
…for release

git-svn-id: http://svn.php.net/repository/pear/packages/DBA/trunk@96921 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Brent Cook committed Sep 26, 2002
1 parent bedc44d commit 09ca93b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 43 deletions.
11 changes: 10 additions & 1 deletion DBA.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,21 @@
* 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
*
Expand Down
2 changes: 1 addition & 1 deletion DBA/Compatibility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion DBA/Driver/Builtin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
// }}}
Expand Down
10 changes: 5 additions & 5 deletions DBA/Driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
}
// }}}
Expand Down Expand Up @@ -242,8 +244,6 @@ function close()
$this->_writable = false;
fclose($this->_idxFP);
fclose($this->_datFP);
} else {
return $this->raiseError('No database was open');
}
}
// }}}
Expand Down
12 changes: 8 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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="/">
Expand Down
64 changes: 33 additions & 31 deletions tests/test_file_driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 09ca93b

Please sign in to comment.