/** * Creates a new table. Note, this is a static function, and operates * independently of a table object. It no longer closes an open table. * * @param string $tableName name of the table to create * @param array $schema field schema for the table * @return object PEAR_Error on failure */ function create($tableName, $schema, $driver, $format = 'php') { // validate the schema $v_schema = DBA_Table::_validateSchema($schema); if (PEAR::isError($v_schema)) { return $v_schema; } // pack the schema $packedSchema = DBA_Table::_packSchema($v_schema + array('_rowid' => array('type' => 'integer', 'default' => 0, 'auto_increment' => true), '_timestamp' => array('type' => 'timestamp', 'default' => 'time()', 'default_type' => 'function'))); if (PEAR::isError($packedSchema)) { return $packedSchema; } $dba = DBA::create($driver); if (PEAR::isError($dba)) { return $dba; } $r = $dba->open($tableName, 'n'); if (PEAR::isError($r)) { return $r; } $r = $dba->insert(DBA_SCHEMA_KEY, $packedSchema); if (PEAR::isError($r)) { return $r; } $r = $dba->close(); if (PEAR::isError($r)) { return $r; } }
echo $result->getMessage() . "\n"; exit; } $key = $testDB->firstkey(); while ($key !== FALSE) { echo "{$key} = " . $testDB->fetch($key) . "\n"; $key = $testDB->nextkey($key); } if (PEAR::isError($result = $testDB->close())) { echo $result->getMessage(); exit; } if (PEAR::isError($result = $testDB->drop())) { echo $result->getMessage(); exit; } } echo "Testing static drop functionality\n"; // test static drop foreach ($testDrivers as $driver) { echo "Testing {$driver} driver\n\n"; $testDB =& DBA::create($driver); if (PEAR::isError($result = $testDB->open('test_db', 'c'))) { echo $result->getMessage() . "\n"; exit; } if (PEAR::isError($result = DBA::db_drop('test_db', $driver))) { echo $result->getMessage(); exit; } }