Back to index

php5  5.3.10
testdb.inc
Go to the documentation of this file.
00001 <?php /* $Id: testdb.inc 161049 2004-06-11 01:37:06Z abies $ */
00002 
00003 $user = 'SYSDBA';
00004 $password = 'masterkey';
00005 ini_set('ibase.default_user',$user);
00006 ini_set('ibase.default_password',$password);
00007 
00008 /* we need just the generated name, not the file itself */
00009 unlink($test_base = tempnam('/tmp',"php_ibase_test"));
00010 
00011 function init_db()
00012 {
00013        global $test_base, $user, $password;
00014 
00015        $test_db = ibase_query(IBASE_CREATE,sprintf("CREATE DATABASE '%s' USER '%s' PASSWORD '%s'",
00016               $test_base, $user, $password));
00017        $tr = ibase_trans($test_db);
00018        ibase_query($tr,"create table test1 (i integer, c varchar(100))");
00019        ibase_commit_ret($tr);
00020        ibase_query($tr,"insert into test1(i, c) values(1, 'test table not created with isql')");
00021        ibase_commit($tr);
00022        ibase_close($test_db);
00023 }
00024 
00025 function cleanup_db()
00026 {
00027        global $test_base;
00028     
00029        $r = ibase_connect($test_base);
00030        ibase_drop_db($r);
00031 }
00032 
00033 register_shutdown_function('cleanup_db');
00034 init_db();