cvs: php-src(PHP_4_3) /ext/interbase/tests 002.phpt 003.phpt 004.phpt 005.phpt 006.phpt
| From: | Ard Biesheuvel | Date: | Sun, 15 Feb 2004 20:47:22 +0000 |
| Subject: | cvs: php-src(PHP_4_3) /ext/interbase/tests 002.phpt 003.phpt 004.phpt 005.phpt 006.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-26217@lists.php.net to get a copy of this message | ||
abies Sun Feb 15 15:47:22 2004 EDT
Modified files: (Branch: PHP_4_3)
/php-src/ext/interbase/tests 002.phpt 003.phpt 004.phpt 005.phpt
006.phpt
Log:
CS/WS
http://cvs.php.net/diff.php/php-src/ext/interbase/tests/002.phpt?r1=1.2.4.2&r2=1.2.4.3&ty=u Index: php-src/ext/interbase/tests/002.phpt diff -u php-src/ext/interbase/tests/002.phpt:1.2.4.2 php-src/ext/interbase/tests/002.phpt:1.2.4.3 --- php-src/ext/interbase/tests/002.phpt:1.2.4.2 Sat Aug 16 16:05:36 2003 +++ php-src/ext/interbase/tests/002.phpt Sun Feb 15 15:47:21 2004 @@ -5,23 +5,23 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 002.phpt,v 1.2.4.2 2003/08/16 20:05:36 abies Exp $ */ +<?php /* $Id: 002.phpt,v 1.2.4.3 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - out_table("test1"); - ibase_close(); +require("interbase.inc"); - $con = ibase_connect($test_base); - $pcon1 = ibase_pconnect($test_base); - $pcon2 = ibase_pconnect($test_base); - ibase_close($con); - ibase_close($pcon1); +ibase_connect($test_base); +out_table("test1"); +ibase_close(); - out_table("test1"); +$con = ibase_connect($test_base); +$pcon1 = ibase_pconnect($test_base); +$pcon2 = ibase_pconnect($test_base); +ibase_close($con); +ibase_close($pcon1); - ibase_close($pcon2); +out_table("test1"); + +ibase_close($pcon2); ?> --EXPECT-- --- test1 --- http://cvs.php.net/diff.php/php-src/ext/interbase/tests/003.phpt?r1=1.2.4.4&r2=1.2.4.5&ty=u Index: php-src/ext/interbase/tests/003.phpt diff -u php-src/ext/interbase/tests/003.phpt:1.2.4.4 php-src/ext/interbase/tests/003.phpt:1.2.4.5 --- php-src/ext/interbase/tests/003.phpt:1.2.4.4 Sun Feb 15 13:45:56 2004 +++ php-src/ext/interbase/tests/003.phpt Sun Feb 15 15:47:21 2004 @@ -5,130 +5,132 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 003.phpt,v 1.2.4.4 2004/02/15 18:45:56 abies Exp $ */ +<?php /* $Id: 003.phpt,v 1.2.4.5 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - ibase_connect($test_base); - - ibase_query( - "create table test3 ( - iter integer not null, - v_char char(1000), - v_date timestamp, - v_decimal4_2 decimal(4,2), - v_decimal4_0 decimal(4,0), - v_decimal7_2 decimal(7,2), - v_decimal7_0 decimal(7,0), - v_numeric15_15 numeric(15,15), - v_numeric15_0 numeric(15,0), - v_double double precision, - v_float float, - v_integer integer, - v_smallint smallint, - v_varchar varchar(10000) - )"); - ibase_commit(); - - /* should fail, but gracefully */ - @ibase_query("insert into test3 (iter) values (?)", null); - - /* if timefmt is not supported, suppress error here */ - @ibase_timefmt("%m/%d/%Y %H:%M:%S"); - - for($iter = 0; $iter < 10; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal4_2 = rand_number(4,2); - $v_decimal4_0 = rand_number(4,0); - $v_decimal7_2 = rand_number(7,2); - $v_decimal7_0 = rand_number(7,0); - $v_numeric15_15 = rand_number(15,15); - $v_numeric15_0 = $iter ? rand_number(15,0) : 0; - $v_double = rand_number(18); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - ibase_query( - "insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar) - values ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,$v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')"); - $sel = ibase_query("select * from test3 where iter = $iter"); - $row = ibase_fetch_object($sel); - if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){ - echo " CHAR fail:\n"; - echo " in: $v_char\n"; - echo " out: $row->V_CHAR\n"; - } - if($row->V_DATE != $v_date){ - echo " DATE fail\n"; - echo " in: $v_date\n"; - echo " out: $row->V_DATE\n"; - } - if($row->V_DECIMAL4_2 != $v_decimal4_2){ - echo " DECIMAL4_2 fail\n"; - echo " in: $v_decimal4_2\n"; - echo " out: $row->V_DECIMAL4_2\n"; - } - if($row->V_DECIMAL4_0 != $v_decimal4_0){ - echo " DECIMAL4_0 fail\n"; - echo " in: $v_decimal4_0\n"; - echo " out: $row->V_DECIMAL4_0\n"; - } - if($row->V_DECIMAL7_2 != $v_decimal7_2){ - echo " DECIMAL7_2 fail\n"; - echo " in: $v_decimal7_2\n"; - echo " out: $row->V_DECIMAL7_2\n"; - } - if($row->V_DECIMAL7_0 != $v_decimal7_0){ - echo " DECIMAL7_0 fail\n"; - echo " in: $v_decimal7_0\n"; - echo " out: $row->V_DECIMAL7_0\n"; - } - if($row->V_NUMERIC15_15 != $v_numeric15_15){ - echo " NUMERIC15_15 fail\n"; - echo " in: $v_numeric15_15\n"; - echo " out: $row->V_NUMERIC15_15\n"; - } - if($row->V_NUMERIC15_0 != (string)$v_numeric15_0){ - echo " NUMERIC15_0 fail\n"; - echo " in: $v_numeric15_0\n"; - echo " out: $row->V_NUMERIC15_0\n"; - } - - if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ - echo " DOUBLE fail\n"; - echo " in: $v_double\n"; - echo " out: $row->V_DOUBLE\n"; - } - if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ - echo " FLOAT fail\n"; - echo " in: $v_float\n"; - echo " out: $row->V_FLOAT\n"; - } - if($row->V_INTEGER != $v_integer){ - echo " INTEGER fail\n"; - echo " in: $v_integer\n"; - echo " out: $row->V_INTEGER\n"; - } - if($row->V_SMALLINT != $v_smallint){ - echo " SMALLINT fail\n"; - echo " in: $v_smallint\n"; - echo " out: $row->V_SMALLINT\n"; - } - - if(substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar){ - echo " VARCHAR fail:\n"; - echo " in: $v_varchar\n"; - echo " out: $row->V_VARCHAR\n"; - } - - ibase_free_result($sel); - } /* for($iter) */ +require("interbase.inc"); - ibase_close(); - echo "end of test\n"; +ibase_connect($test_base); + +ibase_query( + "CREATE TABLE test3 ( + iter integer not null, + v_char char(1000), + v_date timestamp, + v_decimal4_2 decimal(4,2), + v_decimal4_0 decimal(4,0), + v_decimal7_2 decimal(7,2), + v_decimal7_0 decimal(7,0), + v_numeric15_15 numeric(15,15), + v_numeric15_0 numeric(15,0), + v_double double precision, + v_float float, + v_integer integer, + v_smallint smallint, + v_varchar varchar(10000) + )"); +ibase_commit(); + +/* should fail, but gracefully */ +@ibase_query("INSERT INTO test3 (iter) VALUES (?)", null); + +/* if timefmt is not supported, suppress error here */ +@ibase_timefmt("%m/%d/%Y %H:%M:%S"); + +for ($iter = 0; $iter < 10; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal4_2 = rand_number(4,2); + $v_decimal4_0 = rand_number(4,0); + $v_decimal7_2 = rand_number(7,2); + $v_decimal7_0 = rand_number(7,0); + $v_numeric15_15 = rand_number(15,15); + $v_numeric15_0 = $iter ? rand_number(15,0) : 0; + $v_double = rand_number(18); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + ibase_query( + "INSERT INTO test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0, + v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar) + VALUES ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0, + $v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')"); + + $sel = ibase_query('SELECT * FROM test3 WHERE iter = ?',$iter); + $row = ibase_fetch_object($sel); + if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) { + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if ($row->V_DATE != $v_date) { + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if ($row->V_DECIMAL4_2 != $v_decimal4_2) { + echo " DECIMAL4_2 fail\n"; + echo " in: $v_decimal4_2\n"; + echo " out: $row->V_DECIMAL4_2\n"; + } + if ($row->V_DECIMAL4_0 != $v_decimal4_0) { + echo " DECIMAL4_0 fail\n"; + echo " in: $v_decimal4_0\n"; + echo " out: $row->V_DECIMAL4_0\n"; + } + if ($row->V_DECIMAL7_2 != $v_decimal7_2) { + echo " DECIMAL7_2 fail\n"; + echo " in: $v_decimal7_2\n"; + echo " out: $row->V_DECIMAL7_2\n"; + } + if ($row->V_DECIMAL7_0 != $v_decimal7_0) { + echo " DECIMAL7_0 fail\n"; + echo " in: $v_decimal7_0\n"; + echo " out: $row->V_DECIMAL7_0\n"; + } + if ($row->V_NUMERIC15_15 != $v_numeric15_15) { + echo " NUMERIC15_15 fail\n"; + echo " in: $v_numeric15_15\n"; + echo " out: $row->V_NUMERIC15_15\n"; + } + if ($row->V_NUMERIC15_0 != (string)$v_numeric15_0) { + echo " NUMERIC15_0 fail\n"; + echo " in: $v_numeric15_0\n"; + echo " out: $row->V_NUMERIC15_0\n"; + } + if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) { + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) { + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if ($row->V_INTEGER != $v_integer) { + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + if ($row->V_SMALLINT != $v_smallint) { + echo " SMALLINT fail\n"; + echo " in: $v_smallint\n"; + echo " out: $row->V_SMALLINT\n"; + } + if (substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar) { + echo " VARCHAR fail:\n"; + echo " in: $v_varchar\n"; + echo " out: $row->V_VARCHAR\n"; + } + + ibase_free_result($sel); +} /* for($iter) */ + +ibase_close(); +echo "end of test\n"; ?> --EXPECT-- end of test http://cvs.php.net/diff.php/php-src/ext/interbase/tests/004.phpt?r1=1.2.4.5&r2=1.2.4.6&ty=u Index: php-src/ext/interbase/tests/004.phpt diff -u php-src/ext/interbase/tests/004.phpt:1.2.4.5 php-src/ext/interbase/tests/004.phpt:1.2.4.6 --- php-src/ext/interbase/tests/004.phpt:1.2.4.5 Sun Aug 17 12:40:26 2003 +++ php-src/ext/interbase/tests/004.phpt Sun Feb 15 15:47:21 2004 @@ -5,116 +5,118 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 004.phpt,v 1.2.4.6 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - - ibase_query( - "create table test4 ( - v_integer integer, - v_blob blob)"); - ibase_commit(); - - /* create 100k blob file */ - $blob_str = rand_binstr(100*1024); - - $name = tempnam(dirname(__FILE__),"blob.tmp"); - $ftmp = fopen($name,"w"); - fwrite($ftmp,$blob_str); - fclose($ftmp); - - echo "import blob 1\n"; - $ftmp = fopen($name,"r"); - $bl_s = ibase_blob_import($ftmp); - ibase_query("insert into test4 (v_integer, v_blob) values (1, ?)", $bl_s); - - echo "test blob 1\n"; - $q = ibase_query("select v_blob from test4 where v_integer = 1"); - $row = ibase_fetch_object($q); - $bl_h = ibase_blob_open($row->V_BLOB); - - $blob = ''; - while($piece = ibase_blob_get($bl_h, 1 + rand() % 1024)) - $blob .= $piece; - if($blob != $blob_str) - echo " BLOB 1 fail (1)\n"; - ibase_blob_close($bl_h); - - $bl_h = ibase_blob_open($row->V_BLOB); - - $blob = ''; - while($piece = ibase_blob_get($bl_h, 100 * 1024)) - $blob .= $piece; - if($blob != $blob_str) - echo " BLOB 1 fail (2)\n"; - ibase_blob_close($bl_h); - ibase_free_result($q); - unset($blob); - - echo "create blob 2\n"; - - ibase_query("insert into test4 (v_integer, v_blob) values (2, ?)", $blob_str); - - echo "test blob 2\n"; - - $q = ibase_query("select v_blob from test4 where v_integer = 2"); - $row = ibase_fetch_object($q,IBASE_TEXT); - - if($row->V_BLOB != $blob_str) - echo " BLOB 2 fail\n"; - ibase_free_result($q); - unset($blob); - - - echo "create blob 3\n"; - - $bl_h = ibase_blob_create(); - - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n"); - ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n"); - ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n"); - ibase_blob_add($bl_h, "| any later version. |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n"); - ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n"); - ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"); - ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"); - ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n"); - ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n"); - ibase_blob_add($bl_h, "| contact core@php.net. |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - $bl_s = ibase_blob_close($bl_h); - ibase_query("insert into test4 (v_integer, v_blob) values (3, ?)", $bl_s); - - echo "echo blob 3\n"; - - $q = ibase_query("select v_blob from test4 where v_integer = 3"); - $row = ibase_fetch_object($q); - ibase_blob_echo($row->V_BLOB); - ibase_free_result($q); - - echo "fetch blob 3\n"; - $q = ibase_query("select v_blob from test4 where v_integer = 3"); - $row = ibase_fetch_object($q,IBASE_TEXT); - echo $row->V_BLOB; - ibase_free_result($q); - - ibase_close(); - unlink($name); - echo "end of test\n"; +require("interbase.inc"); + +ibase_connect($test_base); + +ibase_query( + "CREATE TABLE test4 ( + v_integer integer, + v_blob blob)"); +ibase_commit(); + +/* create 100k blob file */ +$blob_str = rand_binstr(100*1024); + +$name = tempnam(dirname(__FILE__),"blob.tmp"); +$ftmp = fopen($name,"w"); +fwrite($ftmp,$blob_str); +fclose($ftmp); + +echo "import blob 1\n"; + +$ftmp = fopen($name,"r"); +$bl_s = ibase_blob_import($ftmp); +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (1, ?)", $bl_s); + +echo "test blob 1\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 1"); +$row = ibase_fetch_object($q); +$bl_h = ibase_blob_open($row->V_BLOB); + +$blob = ''; +while ($piece = ibase_blob_get($bl_h, 1 + rand() % 1024)) + $blob .= $piece; +if ($blob != $blob_str) + echo " BLOB 1 fail (1)\n"; +ibase_blob_close($bl_h); + +$bl_h = ibase_blob_open($row->V_BLOB); + +$blob = ''; +while ($piece = ibase_blob_get($bl_h, 100 * 1024)) + $blob .= $piece; +if ($blob != $blob_str) + echo " BLOB 1 fail (2)\n"; +ibase_blob_close($bl_h); +ibase_free_result($q); +unset($blob); + +echo "create blob 2\n"; + +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (2, ?)", $blob_str); + +echo "test blob 2\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 2"); +$row = ibase_fetch_object($q,IBASE_TEXT); + +if ($row->V_BLOB != $blob_str) + echo " BLOB 2 fail\n"; +ibase_free_result($q); +unset($blob); + +echo "create blob 3\n"; + +$bl_h = ibase_blob_create(); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n"); +ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n"); +ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n"); +ibase_blob_add($bl_h, "| any later version. |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n"); +ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n"); +ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"); +ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"); +ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n"); +ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n"); +ibase_blob_add($bl_h, "| contact core@php.net. |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +$bl_s = ibase_blob_close($bl_h); +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (3, ?)", $bl_s); + +echo "echo blob 3\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3"); +$row = ibase_fetch_object($q); +ibase_blob_echo($row->V_BLOB); +ibase_free_result($q); + +echo "fetch blob 3\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3"); +$row = ibase_fetch_object($q,IBASE_TEXT); +echo $row->V_BLOB; +ibase_free_result($q); + +ibase_close(); +unlink($name); + +echo "end of test\n"; ?> --EXPECT-- import blob 1 http://cvs.php.net/diff.php/php-src/ext/interbase/tests/005.phpt?r1=1.2.4.3&r2=1.2.4.4&ty=u Index: php-src/ext/interbase/tests/005.phpt diff -u php-src/ext/interbase/tests/005.phpt:1.2.4.3 php-src/ext/interbase/tests/005.phpt:1.2.4.4 --- php-src/ext/interbase/tests/005.phpt:1.2.4.3 Wed Jul 23 22:47:11 2003 +++ php-src/ext/interbase/tests/005.phpt Sun Feb 15 15:47:21 2004 @@ -5,19 +5,19 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 005.phpt,v 1.2.4.4 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); +require("interbase.inc"); - @ibase_query("create table test5 (i integer)"); - @ibase_query("delete from test5"); - ibase_close(); +ibase_connect($test_base); +@ibase_query("CREATE TABLE test5 (i integer)"); +@ibase_query("DELETE FROM test5"); +ibase_close(); + + +echo "default transaction:\n"; - echo "default transaction:\n"; - /* Difference between default and other transactions: default commited when you call ibase_close(). @@ -32,35 +32,35 @@ /* simple default transaction test without ibase_trans() */ - - ibase_connect($test_base); - echo "empty table\n"; +ibase_connect($test_base); + +echo "empty table\n"; + +/* out_table call ibase_query() + and ibase_query() start default transaction */ +out_table("test5"); + +/* in default transaction context */ +ibase_query("INSERT INTO test5 (i) VALUES (1)"); + +echo "one row\n"; +out_table("test5"); + +ibase_rollback(); /* default rolled */ + +echo "after rollback table empty again\n"; +out_table("test5"); /* started new default transaction */ - /* out_table call ibase_query() - and ibase_query() start default transaction */ - out_table("test5"); - - /* in default transaction context */ - ibase_query("insert into test5 (i) values (1)"); - - echo "one row\n"; - out_table("test5"); - - ibase_rollback(); /* default rolled */ - - echo "after rollback table empty again\n"; - out_table("test5"); /* started new default transaction */ - - ibase_query("insert into test5 (i) values (2)"); - - ibase_close(); /* commit here! */ - - ibase_connect($test_base); - - echo "one row\n"; - out_table("test5"); - ibase_close(); +ibase_query("INSERT INTO test5 (i) VALUES (2)"); + +ibase_close(); /* commit here! */ + +ibase_connect($test_base); + +echo "one row\n"; +out_table("test5"); +ibase_close(); /* default transaction on default link @@ -68,145 +68,145 @@ $tr_def_l1 may be ommited. All queryes without link and trans parameters run in this context */ - - $link_def = ibase_connect($test_base); - - $tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */ - - /* all default */ - $res = ibase_query("select * from test5"); - - echo "one row\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* specify transaction context... */ - $res = ibase_query($tr_def_l1, "select * from test5"); - - echo "one row... again.\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* specify default transaction on link */ - $res = ibase_query($link_def, "select * from test5"); - - echo "one row.\n"; - out_result($res,"test5"); - ibase_free_result($res); +$link_def = ibase_connect($test_base); + +$tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */ + +/* all default */ +$res = ibase_query("SELECT * FROM test5"); + +echo "one row\n"; +out_result($res,"test5"); + +ibase_free_result($res); - ibase_rollback($link_def); /* just for example */ +/* specify transaction context... */ +$res = ibase_query($tr_def_l1, "SELECT * FROM test5"); + +echo "one row... again.\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* specify default transaction on link */ +$res = ibase_query($link_def, "SELECT * FROM test5"); + +echo "one row.\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_rollback($link_def); /* just for example */ + +ibase_close(); - ibase_close(); - /* three transaction on default link */ - ibase_connect($test_base); - - $tr_1 = ibase_trans(); /* this default transaction also */ - $tr_2 = ibase_trans(IBASE_READ); - $tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT); - $tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT); - - $res = ibase_query("select * from test5"); - - echo "one row\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* insert in first transaction context... */ - /* as default */ - ibase_query("insert into test5 (i) values (3)"); - /* specify context */ - ibase_query($tr_1, "insert into test5 (i) values (4)"); - - $res = ibase_query("select * from test5"); - - echo "three rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "three rows again\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_commit($tr_1); - - $tr_1 = ibase_trans(); - ibase_query($tr_1, "insert into test5 (i) values (5)"); - - /* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */ - $res = ibase_query($tr_2, "select * from test5"); - - echo "one row in second transaction\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */ - $res = ibase_query($tr_3, "select * from test5"); - - echo "three rows in third transaction\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */ - $res = ibase_query($tr_4, "select * from test5"); - - echo "three rows in fourth transaction with deadlock\n"; - out_result_trap_error($res,"test5"); - - ibase_free_result($res); - - ibase_rollback($tr_1); - ibase_close(); +ibase_connect($test_base); + +$tr_1 = ibase_trans(); /* this default transaction also */ +$tr_2 = ibase_trans(IBASE_READ); +$tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT); +$tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT); + +$res = ibase_query("select * from test5"); + +echo "one row\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* insert in first transaction context... */ +/* as default */ +ibase_query("INSERT INTO test5 (i) VALUES (3)"); +/* specify context */ +ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (4)"); + +$res = ibase_query("SELECT * FROM test5"); + +echo "three rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "three rows again\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_commit($tr_1); + +$tr_1 = ibase_trans(); + ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)"); + +/* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */ +$res = ibase_query($tr_2, "SELECT * FROM test5"); + +echo "one row in second transaction\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */ +$res = ibase_query($tr_3, "SELECT * FROM test5"); + +echo "three rows in third transaction\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */ +$res = ibase_query($tr_4, "SELECT * FROM test5"); + + echo "three rows in fourth transaction with deadlock\n"; +out_result_trap_error($res,"test5"); + +ibase_free_result($res); + +ibase_rollback($tr_1); +ibase_close(); /* transactions on second link */ - $link_1 = ibase_pconnect($test_base); - $link_2 = ibase_pconnect($test_base); - - $tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */ - $tr_2 = ibase_trans(IBASE_COMMITTED, $link_2); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "three rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_query($tr_1, "insert into test5 (i) values (5)"); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "four rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_commit($tr_1); - - $res = ibase_query($tr_2, "select * from test5"); - - echo "four rows again\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_close($link_1); - ibase_close($link_2); +$link_1 = ibase_pconnect($test_base); +$link_2 = ibase_pconnect($test_base); + +$tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */ +$tr_2 = ibase_trans(IBASE_COMMITTED, $link_2); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "three rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)"); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "four rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_commit($tr_1); + +$res = ibase_query($tr_2, "SELECT * FROM test5"); + +echo "four rows again\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_close($link_1); +ibase_close($link_2); - echo "end of test\n"; +echo "end of test\n"; ?> --EXPECT-- default transaction: http://cvs.php.net/diff.php/php-src/ext/interbase/tests/006.phpt?r1=1.2.4.3&r2=1.2.4.4&ty=u Index: php-src/ext/interbase/tests/006.phpt diff -u php-src/ext/interbase/tests/006.phpt:1.2.4.3 php-src/ext/interbase/tests/006.phpt:1.2.4.4 --- php-src/ext/interbase/tests/006.phpt:1.2.4.3 Wed Sep 3 18:07:31 2003 +++ php-src/ext/interbase/tests/006.phpt Sun Feb 15 15:47:21 2004 @@ -5,200 +5,196 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 006.phpt,v 1.2.4.4 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - - ibase_query( - "create table test6 ( - iter integer, - v_char char(1000), - v_date timestamp, - v_decimal decimal(12,3), - v_double double precision, - v_float float, - v_integer integer, - v_numeric numeric(4,2), - v_smallint smallint, - v_varchar varchar(10000) - )"); - ibase_commit(); - - /* if timefmt not supported, hide error */ - @ibase_timefmt("%m/%d/%Y %H:%M:%S"); - - echo "insert\n"; - - for($iter = 0; $iter < 3; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal = rand_number(12,3); - $v_double = rand_number(20); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_numeric = rand_number(4,2); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - ibase_query("insert into test6 - (iter,v_char,v_date,v_decimal,v_double,v_float, - v_integer,v_numeric,v_smallint,v_varchar) - values (?,?,?,?,?,?,?,?,?,?)", - $iter, $v_char, $v_date, $v_decimal, $v_double, $v_float, - $v_integer, $v_numeric, $v_smallint, $v_varchar); - $sel = ibase_query("select * from test6 where iter = $iter"); - - $row = ibase_fetch_object($sel); - if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){ - echo " CHAR fail:\n"; - echo " in: $v_char\n"; - echo " out: $row->V_CHAR\n"; - } - if($row->V_DATE != $v_date){ - echo " DATE fail\n"; - echo " in: $v_date\n"; - echo " out: $row->V_DATE\n"; - } - if($row->V_DECIMAL != $v_decimal){ - echo " DECIMAL fail\n"; - echo " in: $v_decimal\n"; - echo " out: $row->V_DECIMAL\n"; - } - if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ - echo " DOUBLE fail\n"; - echo " in: $v_double\n"; - echo " out: $row->V_DOUBLE\n"; - } - if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ - echo " FLOAT fail\n"; - echo " in: $v_float\n"; - echo " out: $row->V_FLOAT\n"; - } - if($row->V_INTEGER != $v_integer){ - echo " INTEGER fail\n"; - echo " in: $v_integer\n"; - echo " out: $row->V_INTEGER\n"; - } - if ($row->V_NUMERIC != $v_numeric){ - echo " NUMERIC fail\n"; - echo " in: $v_numeric\n"; - echo " out: $row->V_NUMERIC\n"; - } - if ($row->V_SMALLINT != $v_smallint){ - echo " SMALLINT fail\n"; - echo " in: $v_smallint\n"; - echo " out: $row->V_SMALLINT\n"; - } - if ($row->V_VARCHAR != $v_varchar){ - echo " VARCHAR fail:\n"; - echo " in: $v_varchar\n"; - echo " out: $row->V_VARCHAR\n"; - } - ibase_free_result($sel); - }/* for($iter)*/ - - echo "select\n"; - for($iter = 0; $iter < 3; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal = rand_number(12,3); - $v_double = rand_number(20); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_numeric = rand_number(4,2); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - /* clear table*/ - ibase_query("delete from test6"); - - /* make one record */ - ibase_query("insert into test6 - (iter, v_char,v_date,v_decimal, - v_integer,v_numeric,v_smallint,v_varchar) - values (666, '$v_char','$v_date',$v_decimal, $v_integer, - $v_numeric, $v_smallint, '$v_varchar')"); - - /* test all types */ - if(!($sel = ibase_query( - "select iter from test6 where v_char = ?", $v_char))) - echo "CHAR fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_date = ?", $v_date))) - echo "DATE fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_decimal = ?", $v_decimal))) - echo "DECIMAL fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_integer = ?", $v_integer))) - echo "INTEGER fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_numeric = ?", $v_numeric))) - echo "NUMERIC fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_smallint = ?", $v_smallint))) - echo "SMALLINT fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_varchar = ?", $v_varchar))) - echo "VARCHAR fail\n"; - ibase_free_result($sel); - - }/*for iter*/ - - echo "prepare and exec insert\n"; - - /* prepare table */ - ibase_query("delete from test6"); - - /* prepare query */ - $query = ibase_prepare( - "insert into test6 (v_integer) values (?)"); - - for($i = 0; $i < 10; $i++) - ibase_execute($query, $i); - - out_table("test6"); - - ibase_free_query($query); - - - echo "prepare and exec select\n"; - - /* prepare query */ - $query = ibase_prepare("select * from test6 - where v_integer between ? and ?"); - - $low_border = 2; - $high_border = 6; - - $res = ibase_execute($query, $low_border, $high_border); - out_result($res, "test6"); - ibase_free_result($res); - - $low_border = 0; - $high_border = 4; - $res = ibase_execute($query, $low_border, $high_border); - out_result($res, "test6"); - ibase_free_result($res); - - $res = ibase_execute($query, "5", 7.5); - out_result($res, "test6"); - ibase_free_result($res); +require("interbase.inc"); - ibase_free_query($query); +ibase_connect($test_base); - ibase_close(); - echo "end of test\n"; +ibase_query( + "CREATE TABLE test6 ( + iter integer, + v_char char(1000), + v_date timestamp, + v_decimal decimal(12,3), + v_double double precision, + v_float float, + v_integer integer, + v_numeric numeric(4,2), + v_smallint smallint, + v_varchar varchar(10000) + )"); +ibase_commit(); + +/* if timefmt not supported, hide error */ +@ibase_timefmt("%m/%d/%Y %H:%M:%S"); + +echo "insert\n"; + +for ($iter = 0; $iter < 3; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal = rand_number(12,3); + $v_double = rand_number(20); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_numeric = rand_number(4,2); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + ibase_query("INSERT INTO test6 + (iter,v_char,v_date,v_decimal,v_double,v_float, v_integer, + v_numeric,v_smallint,v_varchar) VALUES (?,?,?,?,?,?,?,?,?,?)", + $iter, $v_char, $v_date, $v_decimal, $v_double, $v_float, + $v_integer, $v_numeric, $v_smallint, $v_varchar); + $sel = ibase_query("SELECT * FROM test6 WHERE iter = $iter"); + + $row = ibase_fetch_object($sel); + if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) { + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if ($row->V_DATE != $v_date) { + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if ($row->V_DECIMAL != $v_decimal) { + echo " DECIMAL fail\n"; + echo " in: $v_decimal\n"; + echo " out: $row->V_DECIMAL\n"; + } + if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) { + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) { + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if ($row->V_INTEGER != $v_integer) { + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + if ($row->V_NUMERIC != $v_numeric) { + echo " NUMERIC fail\n"; + echo " in: $v_numeric\n"; + echo " out: $row->V_NUMERIC\n"; + } + if ($row->V_SMALLINT != $v_smallint) { + echo " SMALLINT fail\n"; + echo " in: $v_smallint\n"; + echo " out: $row->V_SMALLINT\n"; + } + if ($row->V_VARCHAR != $v_varchar) { + echo " VARCHAR fail:\n"; + echo " in: $v_varchar\n"; + echo " out: $row->V_VARCHAR\n"; + } + ibase_free_result($sel); +} /* for($iter) */ + +echo "select\n"; +for ($iter = 0; $iter < 3; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal = rand_number(12,3); + $v_double = rand_number(20); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_numeric = rand_number(4,2); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + /* clear table*/ + ibase_query("DELETE FROM test6"); + + /* make one record */ + ibase_query("INSERT INTO test6 (iter, v_char,v_date,v_decimal,v_integer,v_numeric, + v_smallint,v_varchar) VALUES (666, '$v_char','$v_date',$v_decimal, $v_integer, + $v_numeric, $v_smallint, '$v_varchar')"); + + /* test all types */ + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_char = ?", $v_char))) + echo "CHAR fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_date = ?", $v_date))) + echo "DATE fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_decimal = ?", $v_decimal))) + echo "DECIMAL fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_integer = ?", $v_integer))) + echo "INTEGER fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_numeric = ?", $v_numeric))) + echo "NUMERIC fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_smallint = ?", $v_smallint))) + echo "SMALLINT fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_varchar = ?", $v_varchar))) + echo "VARCHAR fail\n"; + ibase_free_result($sel); + +} /* for ($iter) */ + +echo "prepare and exec insert\n"; + +/* prepare table */ +ibase_query("DELETE FROM test6"); + +/* prepare query */ +$query = ibase_prepare( + "INSERT INTO test6 (v_integer) VALUES (?)"); + +for($i = 0; $i < 10; $i++) + ibase_execute($query, $i); + +out_table("test6"); + +ibase_free_query($query); + + +echo "prepare and exec select\n"; + +/* prepare query */ +$query = ibase_prepare("SELECT * FROM test6 WHERE v_integer BETWEEN ? AND ?"); + +$low_border = 2; +$high_border = 6; + +$res = ibase_execute($query, $low_border, $high_border); +out_result($res, "test6"); +ibase_free_result($res); + +$low_border = 0; +$high_border = 4; +$res = ibase_execute($query, $low_border, $high_border); +out_result($res, "test6"); +ibase_free_result($res); + +$res = ibase_execute($query, "5", 7.5); +out_result($res, "test6"); +ibase_free_result($res); + +ibase_free_query($query); + +ibase_close(); +echo "end of test\n"; ?> --EXPECT-- insert
http://cvs.php.net/diff.php/php-src/ext/interbase/tests/002.phpt?r1=1.2.4.2&r2=1.2.4.3&ty=u Index: php-src/ext/interbase/tests/002.phpt diff -u php-src/ext/interbase/tests/002.phpt:1.2.4.2 php-src/ext/interbase/tests/002.phpt:1.2.4.3 --- php-src/ext/interbase/tests/002.phpt:1.2.4.2 Sat Aug 16 16:05:36 2003 +++ php-src/ext/interbase/tests/002.phpt Sun Feb 15 15:47:21 2004 @@ -5,23 +5,23 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 002.phpt,v 1.2.4.2 2003/08/16 20:05:36 abies Exp $ */ +<?php /* $Id: 002.phpt,v 1.2.4.3 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - out_table("test1"); - ibase_close(); +require("interbase.inc"); - $con = ibase_connect($test_base); - $pcon1 = ibase_pconnect($test_base); - $pcon2 = ibase_pconnect($test_base); - ibase_close($con); - ibase_close($pcon1); +ibase_connect($test_base); +out_table("test1"); +ibase_close(); - out_table("test1"); +$con = ibase_connect($test_base); +$pcon1 = ibase_pconnect($test_base); +$pcon2 = ibase_pconnect($test_base); +ibase_close($con); +ibase_close($pcon1); - ibase_close($pcon2); +out_table("test1"); + +ibase_close($pcon2); ?> --EXPECT-- --- test1 --- http://cvs.php.net/diff.php/php-src/ext/interbase/tests/003.phpt?r1=1.2.4.4&r2=1.2.4.5&ty=u Index: php-src/ext/interbase/tests/003.phpt diff -u php-src/ext/interbase/tests/003.phpt:1.2.4.4 php-src/ext/interbase/tests/003.phpt:1.2.4.5 --- php-src/ext/interbase/tests/003.phpt:1.2.4.4 Sun Feb 15 13:45:56 2004 +++ php-src/ext/interbase/tests/003.phpt Sun Feb 15 15:47:21 2004 @@ -5,130 +5,132 @@ --POST-- --GET-- --FILE-- -<?php /* $Id: 003.phpt,v 1.2.4.4 2004/02/15 18:45:56 abies Exp $ */ +<?php /* $Id: 003.phpt,v 1.2.4.5 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - ibase_connect($test_base); - - ibase_query( - "create table test3 ( - iter integer not null, - v_char char(1000), - v_date timestamp, - v_decimal4_2 decimal(4,2), - v_decimal4_0 decimal(4,0), - v_decimal7_2 decimal(7,2), - v_decimal7_0 decimal(7,0), - v_numeric15_15 numeric(15,15), - v_numeric15_0 numeric(15,0), - v_double double precision, - v_float float, - v_integer integer, - v_smallint smallint, - v_varchar varchar(10000) - )"); - ibase_commit(); - - /* should fail, but gracefully */ - @ibase_query("insert into test3 (iter) values (?)", null); - - /* if timefmt is not supported, suppress error here */ - @ibase_timefmt("%m/%d/%Y %H:%M:%S"); - - for($iter = 0; $iter < 10; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal4_2 = rand_number(4,2); - $v_decimal4_0 = rand_number(4,0); - $v_decimal7_2 = rand_number(7,2); - $v_decimal7_0 = rand_number(7,0); - $v_numeric15_15 = rand_number(15,15); - $v_numeric15_0 = $iter ? rand_number(15,0) : 0; - $v_double = rand_number(18); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - ibase_query( - "insert into test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0,v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar) - values ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0,$v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')"); - $sel = ibase_query("select * from test3 where iter = $iter"); - $row = ibase_fetch_object($sel); - if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){ - echo " CHAR fail:\n"; - echo " in: $v_char\n"; - echo " out: $row->V_CHAR\n"; - } - if($row->V_DATE != $v_date){ - echo " DATE fail\n"; - echo " in: $v_date\n"; - echo " out: $row->V_DATE\n"; - } - if($row->V_DECIMAL4_2 != $v_decimal4_2){ - echo " DECIMAL4_2 fail\n"; - echo " in: $v_decimal4_2\n"; - echo " out: $row->V_DECIMAL4_2\n"; - } - if($row->V_DECIMAL4_0 != $v_decimal4_0){ - echo " DECIMAL4_0 fail\n"; - echo " in: $v_decimal4_0\n"; - echo " out: $row->V_DECIMAL4_0\n"; - } - if($row->V_DECIMAL7_2 != $v_decimal7_2){ - echo " DECIMAL7_2 fail\n"; - echo " in: $v_decimal7_2\n"; - echo " out: $row->V_DECIMAL7_2\n"; - } - if($row->V_DECIMAL7_0 != $v_decimal7_0){ - echo " DECIMAL7_0 fail\n"; - echo " in: $v_decimal7_0\n"; - echo " out: $row->V_DECIMAL7_0\n"; - } - if($row->V_NUMERIC15_15 != $v_numeric15_15){ - echo " NUMERIC15_15 fail\n"; - echo " in: $v_numeric15_15\n"; - echo " out: $row->V_NUMERIC15_15\n"; - } - if($row->V_NUMERIC15_0 != (string)$v_numeric15_0){ - echo " NUMERIC15_0 fail\n"; - echo " in: $v_numeric15_0\n"; - echo " out: $row->V_NUMERIC15_0\n"; - } - - if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ - echo " DOUBLE fail\n"; - echo " in: $v_double\n"; - echo " out: $row->V_DOUBLE\n"; - } - if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ - echo " FLOAT fail\n"; - echo " in: $v_float\n"; - echo " out: $row->V_FLOAT\n"; - } - if($row->V_INTEGER != $v_integer){ - echo " INTEGER fail\n"; - echo " in: $v_integer\n"; - echo " out: $row->V_INTEGER\n"; - } - if($row->V_SMALLINT != $v_smallint){ - echo " SMALLINT fail\n"; - echo " in: $v_smallint\n"; - echo " out: $row->V_SMALLINT\n"; - } - - if(substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar){ - echo " VARCHAR fail:\n"; - echo " in: $v_varchar\n"; - echo " out: $row->V_VARCHAR\n"; - } - - ibase_free_result($sel); - } /* for($iter) */ +require("interbase.inc"); - ibase_close(); - echo "end of test\n"; +ibase_connect($test_base); + +ibase_query( + "CREATE TABLE test3 ( + iter integer not null, + v_char char(1000), + v_date timestamp, + v_decimal4_2 decimal(4,2), + v_decimal4_0 decimal(4,0), + v_decimal7_2 decimal(7,2), + v_decimal7_0 decimal(7,0), + v_numeric15_15 numeric(15,15), + v_numeric15_0 numeric(15,0), + v_double double precision, + v_float float, + v_integer integer, + v_smallint smallint, + v_varchar varchar(10000) + )"); +ibase_commit(); + +/* should fail, but gracefully */ +@ibase_query("INSERT INTO test3 (iter) VALUES (?)", null); + +/* if timefmt is not supported, suppress error here */ +@ibase_timefmt("%m/%d/%Y %H:%M:%S"); + +for ($iter = 0; $iter < 10; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal4_2 = rand_number(4,2); + $v_decimal4_0 = rand_number(4,0); + $v_decimal7_2 = rand_number(7,2); + $v_decimal7_0 = rand_number(7,0); + $v_numeric15_15 = rand_number(15,15); + $v_numeric15_0 = $iter ? rand_number(15,0) : 0; + $v_double = rand_number(18); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + ibase_query( + "INSERT INTO test3 (iter, v_char,v_date,v_decimal4_2, v_decimal4_0, v_decimal7_2, v_decimal7_0, + v_numeric15_15, v_numeric15_0,v_double,v_float,v_integer,v_smallint,v_varchar) + VALUES ($iter, '$v_char','$v_date',$v_decimal4_2, $v_decimal4_0, $v_decimal7_2, $v_decimal7_0, + $v_numeric15_15, $v_numeric15_0,$v_double,$v_float,$v_integer,$v_smallint,'$v_varchar')"); + + $sel = ibase_query('SELECT * FROM test3 WHERE iter = ?',$iter); + $row = ibase_fetch_object($sel); + if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) { + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if ($row->V_DATE != $v_date) { + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if ($row->V_DECIMAL4_2 != $v_decimal4_2) { + echo " DECIMAL4_2 fail\n"; + echo " in: $v_decimal4_2\n"; + echo " out: $row->V_DECIMAL4_2\n"; + } + if ($row->V_DECIMAL4_0 != $v_decimal4_0) { + echo " DECIMAL4_0 fail\n"; + echo " in: $v_decimal4_0\n"; + echo " out: $row->V_DECIMAL4_0\n"; + } + if ($row->V_DECIMAL7_2 != $v_decimal7_2) { + echo " DECIMAL7_2 fail\n"; + echo " in: $v_decimal7_2\n"; + echo " out: $row->V_DECIMAL7_2\n"; + } + if ($row->V_DECIMAL7_0 != $v_decimal7_0) { + echo " DECIMAL7_0 fail\n"; + echo " in: $v_decimal7_0\n"; + echo " out: $row->V_DECIMAL7_0\n"; + } + if ($row->V_NUMERIC15_15 != $v_numeric15_15) { + echo " NUMERIC15_15 fail\n"; + echo " in: $v_numeric15_15\n"; + echo " out: $row->V_NUMERIC15_15\n"; + } + if ($row->V_NUMERIC15_0 != (string)$v_numeric15_0) { + echo " NUMERIC15_0 fail\n"; + echo " in: $v_numeric15_0\n"; + echo " out: $row->V_NUMERIC15_0\n"; + } + if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) { + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) { + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if ($row->V_INTEGER != $v_integer) { + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + if ($row->V_SMALLINT != $v_smallint) { + echo " SMALLINT fail\n"; + echo " in: $v_smallint\n"; + echo " out: $row->V_SMALLINT\n"; + } + if (substr($row->V_VARCHAR,0,strlen($v_varchar)) != $v_varchar) { + echo " VARCHAR fail:\n"; + echo " in: $v_varchar\n"; + echo " out: $row->V_VARCHAR\n"; + } + + ibase_free_result($sel); +} /* for($iter) */ + +ibase_close(); +echo "end of test\n"; ?> --EXPECT-- end of test http://cvs.php.net/diff.php/php-src/ext/interbase/tests/004.phpt?r1=1.2.4.5&r2=1.2.4.6&ty=u Index: php-src/ext/interbase/tests/004.phpt diff -u php-src/ext/interbase/tests/004.phpt:1.2.4.5 php-src/ext/interbase/tests/004.phpt:1.2.4.6 --- php-src/ext/interbase/tests/004.phpt:1.2.4.5 Sun Aug 17 12:40:26 2003 +++ php-src/ext/interbase/tests/004.phpt Sun Feb 15 15:47:21 2004 @@ -5,116 +5,118 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 004.phpt,v 1.2.4.6 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - - ibase_query( - "create table test4 ( - v_integer integer, - v_blob blob)"); - ibase_commit(); - - /* create 100k blob file */ - $blob_str = rand_binstr(100*1024); - - $name = tempnam(dirname(__FILE__),"blob.tmp"); - $ftmp = fopen($name,"w"); - fwrite($ftmp,$blob_str); - fclose($ftmp); - - echo "import blob 1\n"; - $ftmp = fopen($name,"r"); - $bl_s = ibase_blob_import($ftmp); - ibase_query("insert into test4 (v_integer, v_blob) values (1, ?)", $bl_s); - - echo "test blob 1\n"; - $q = ibase_query("select v_blob from test4 where v_integer = 1"); - $row = ibase_fetch_object($q); - $bl_h = ibase_blob_open($row->V_BLOB); - - $blob = ''; - while($piece = ibase_blob_get($bl_h, 1 + rand() % 1024)) - $blob .= $piece; - if($blob != $blob_str) - echo " BLOB 1 fail (1)\n"; - ibase_blob_close($bl_h); - - $bl_h = ibase_blob_open($row->V_BLOB); - - $blob = ''; - while($piece = ibase_blob_get($bl_h, 100 * 1024)) - $blob .= $piece; - if($blob != $blob_str) - echo " BLOB 1 fail (2)\n"; - ibase_blob_close($bl_h); - ibase_free_result($q); - unset($blob); - - echo "create blob 2\n"; - - ibase_query("insert into test4 (v_integer, v_blob) values (2, ?)", $blob_str); - - echo "test blob 2\n"; - - $q = ibase_query("select v_blob from test4 where v_integer = 2"); - $row = ibase_fetch_object($q,IBASE_TEXT); - - if($row->V_BLOB != $blob_str) - echo " BLOB 2 fail\n"; - ibase_free_result($q); - unset($blob); - - - echo "create blob 3\n"; - - $bl_h = ibase_blob_create(); - - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n"); - ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n"); - ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n"); - ibase_blob_add($bl_h, "| any later version. |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n"); - ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n"); - ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"); - ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"); - ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n"); - ibase_blob_add($bl_h, "| |\n"); - ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n"); - ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n"); - ibase_blob_add($bl_h, "| contact core@php.net. |\n"); - ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); - $bl_s = ibase_blob_close($bl_h); - ibase_query("insert into test4 (v_integer, v_blob) values (3, ?)", $bl_s); - - echo "echo blob 3\n"; - - $q = ibase_query("select v_blob from test4 where v_integer = 3"); - $row = ibase_fetch_object($q); - ibase_blob_echo($row->V_BLOB); - ibase_free_result($q); - - echo "fetch blob 3\n"; - $q = ibase_query("select v_blob from test4 where v_integer = 3"); - $row = ibase_fetch_object($q,IBASE_TEXT); - echo $row->V_BLOB; - ibase_free_result($q); - - ibase_close(); - unlink($name); - echo "end of test\n"; +require("interbase.inc"); + +ibase_connect($test_base); + +ibase_query( + "CREATE TABLE test4 ( + v_integer integer, + v_blob blob)"); +ibase_commit(); + +/* create 100k blob file */ +$blob_str = rand_binstr(100*1024); + +$name = tempnam(dirname(__FILE__),"blob.tmp"); +$ftmp = fopen($name,"w"); +fwrite($ftmp,$blob_str); +fclose($ftmp); + +echo "import blob 1\n"; + +$ftmp = fopen($name,"r"); +$bl_s = ibase_blob_import($ftmp); +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (1, ?)", $bl_s); + +echo "test blob 1\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 1"); +$row = ibase_fetch_object($q); +$bl_h = ibase_blob_open($row->V_BLOB); + +$blob = ''; +while ($piece = ibase_blob_get($bl_h, 1 + rand() % 1024)) + $blob .= $piece; +if ($blob != $blob_str) + echo " BLOB 1 fail (1)\n"; +ibase_blob_close($bl_h); + +$bl_h = ibase_blob_open($row->V_BLOB); + +$blob = ''; +while ($piece = ibase_blob_get($bl_h, 100 * 1024)) + $blob .= $piece; +if ($blob != $blob_str) + echo " BLOB 1 fail (2)\n"; +ibase_blob_close($bl_h); +ibase_free_result($q); +unset($blob); + +echo "create blob 2\n"; + +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (2, ?)", $blob_str); + +echo "test blob 2\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 2"); +$row = ibase_fetch_object($q,IBASE_TEXT); + +if ($row->V_BLOB != $blob_str) + echo " BLOB 2 fail\n"; +ibase_free_result($q); +unset($blob); + +echo "create blob 3\n"; + +$bl_h = ibase_blob_create(); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n"); +ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n"); +ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n"); +ibase_blob_add($bl_h, "| any later version. |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n"); +ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n"); +ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n"); +ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n"); +ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n"); +ibase_blob_add($bl_h, "| |\n"); +ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n"); +ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n"); +ibase_blob_add($bl_h, "| contact core@php.net. |\n"); +ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n"); +$bl_s = ibase_blob_close($bl_h); +ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (3, ?)", $bl_s); + +echo "echo blob 3\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3"); +$row = ibase_fetch_object($q); +ibase_blob_echo($row->V_BLOB); +ibase_free_result($q); + +echo "fetch blob 3\n"; + +$q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3"); +$row = ibase_fetch_object($q,IBASE_TEXT); +echo $row->V_BLOB; +ibase_free_result($q); + +ibase_close(); +unlink($name); + +echo "end of test\n"; ?> --EXPECT-- import blob 1 http://cvs.php.net/diff.php/php-src/ext/interbase/tests/005.phpt?r1=1.2.4.3&r2=1.2.4.4&ty=u Index: php-src/ext/interbase/tests/005.phpt diff -u php-src/ext/interbase/tests/005.phpt:1.2.4.3 php-src/ext/interbase/tests/005.phpt:1.2.4.4 --- php-src/ext/interbase/tests/005.phpt:1.2.4.3 Wed Jul 23 22:47:11 2003 +++ php-src/ext/interbase/tests/005.phpt Sun Feb 15 15:47:21 2004 @@ -5,19 +5,19 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 005.phpt,v 1.2.4.4 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); +require("interbase.inc"); - @ibase_query("create table test5 (i integer)"); - @ibase_query("delete from test5"); - ibase_close(); +ibase_connect($test_base); +@ibase_query("CREATE TABLE test5 (i integer)"); +@ibase_query("DELETE FROM test5"); +ibase_close(); + + +echo "default transaction:\n"; - echo "default transaction:\n"; - /* Difference between default and other transactions: default commited when you call ibase_close(). @@ -32,35 +32,35 @@ /* simple default transaction test without ibase_trans() */ - - ibase_connect($test_base); - echo "empty table\n"; +ibase_connect($test_base); + +echo "empty table\n"; + +/* out_table call ibase_query() + and ibase_query() start default transaction */ +out_table("test5"); + +/* in default transaction context */ +ibase_query("INSERT INTO test5 (i) VALUES (1)"); + +echo "one row\n"; +out_table("test5"); + +ibase_rollback(); /* default rolled */ + +echo "after rollback table empty again\n"; +out_table("test5"); /* started new default transaction */ - /* out_table call ibase_query() - and ibase_query() start default transaction */ - out_table("test5"); - - /* in default transaction context */ - ibase_query("insert into test5 (i) values (1)"); - - echo "one row\n"; - out_table("test5"); - - ibase_rollback(); /* default rolled */ - - echo "after rollback table empty again\n"; - out_table("test5"); /* started new default transaction */ - - ibase_query("insert into test5 (i) values (2)"); - - ibase_close(); /* commit here! */ - - ibase_connect($test_base); - - echo "one row\n"; - out_table("test5"); - ibase_close(); +ibase_query("INSERT INTO test5 (i) VALUES (2)"); + +ibase_close(); /* commit here! */ + +ibase_connect($test_base); + +echo "one row\n"; +out_table("test5"); +ibase_close(); /* default transaction on default link @@ -68,145 +68,145 @@ $tr_def_l1 may be ommited. All queryes without link and trans parameters run in this context */ - - $link_def = ibase_connect($test_base); - - $tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */ - - /* all default */ - $res = ibase_query("select * from test5"); - - echo "one row\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* specify transaction context... */ - $res = ibase_query($tr_def_l1, "select * from test5"); - - echo "one row... again.\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* specify default transaction on link */ - $res = ibase_query($link_def, "select * from test5"); - - echo "one row.\n"; - out_result($res,"test5"); - ibase_free_result($res); +$link_def = ibase_connect($test_base); + +$tr_def_l1 = ibase_trans(IBASE_READ); /* here transaction start */ + +/* all default */ +$res = ibase_query("SELECT * FROM test5"); + +echo "one row\n"; +out_result($res,"test5"); + +ibase_free_result($res); - ibase_rollback($link_def); /* just for example */ +/* specify transaction context... */ +$res = ibase_query($tr_def_l1, "SELECT * FROM test5"); + +echo "one row... again.\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* specify default transaction on link */ +$res = ibase_query($link_def, "SELECT * FROM test5"); + +echo "one row.\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_rollback($link_def); /* just for example */ + +ibase_close(); - ibase_close(); - /* three transaction on default link */ - ibase_connect($test_base); - - $tr_1 = ibase_trans(); /* this default transaction also */ - $tr_2 = ibase_trans(IBASE_READ); - $tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT); - $tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT); - - $res = ibase_query("select * from test5"); - - echo "one row\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* insert in first transaction context... */ - /* as default */ - ibase_query("insert into test5 (i) values (3)"); - /* specify context */ - ibase_query($tr_1, "insert into test5 (i) values (4)"); - - $res = ibase_query("select * from test5"); - - echo "three rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "three rows again\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_commit($tr_1); - - $tr_1 = ibase_trans(); - ibase_query($tr_1, "insert into test5 (i) values (5)"); - - /* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */ - $res = ibase_query($tr_2, "select * from test5"); - - echo "one row in second transaction\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */ - $res = ibase_query($tr_3, "select * from test5"); - - echo "three rows in third transaction\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - /* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */ - $res = ibase_query($tr_4, "select * from test5"); - - echo "three rows in fourth transaction with deadlock\n"; - out_result_trap_error($res,"test5"); - - ibase_free_result($res); - - ibase_rollback($tr_1); - ibase_close(); +ibase_connect($test_base); + +$tr_1 = ibase_trans(); /* this default transaction also */ +$tr_2 = ibase_trans(IBASE_READ); +$tr_3 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_VERSION+IBASE_WAIT); +$tr_4 = ibase_trans(IBASE_READ+IBASE_COMMITTED+IBASE_REC_NO_VERSION+IBASE_NOWAIT); + +$res = ibase_query("select * from test5"); + +echo "one row\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* insert in first transaction context... */ +/* as default */ +ibase_query("INSERT INTO test5 (i) VALUES (3)"); +/* specify context */ +ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (4)"); + +$res = ibase_query("SELECT * FROM test5"); + +echo "three rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "three rows again\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_commit($tr_1); + +$tr_1 = ibase_trans(); + ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)"); + +/* tr_2 is IBASE_READ + IBASE_CONCURRENCY + IBASE_WAIT */ +$res = ibase_query($tr_2, "SELECT * FROM test5"); + +echo "one row in second transaction\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* tr_3 is IBASE_COMMITTED + IBASE_REC_VERSION + IBASE_WAIT */ +$res = ibase_query($tr_3, "SELECT * FROM test5"); + +echo "three rows in third transaction\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +/* tr_4 IBASE_COMMITED + IBASE_REC_NO_VERSION + IBASE_NOWAIT */ +$res = ibase_query($tr_4, "SELECT * FROM test5"); + + echo "three rows in fourth transaction with deadlock\n"; +out_result_trap_error($res,"test5"); + +ibase_free_result($res); + +ibase_rollback($tr_1); +ibase_close(); /* transactions on second link */ - $link_1 = ibase_pconnect($test_base); - $link_2 = ibase_pconnect($test_base); - - $tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */ - $tr_2 = ibase_trans(IBASE_COMMITTED, $link_2); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "three rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_query($tr_1, "insert into test5 (i) values (5)"); - - $res = ibase_query($tr_1, "select * from test5"); - - echo "four rows\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_commit($tr_1); - - $res = ibase_query($tr_2, "select * from test5"); - - echo "four rows again\n"; - out_result($res,"test5"); - - ibase_free_result($res); - - ibase_close($link_1); - ibase_close($link_2); +$link_1 = ibase_pconnect($test_base); +$link_2 = ibase_pconnect($test_base); + +$tr_1 = ibase_trans(IBASE_DEFAULT, $link_2); /* this default transaction also */ +$tr_2 = ibase_trans(IBASE_COMMITTED, $link_2); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "three rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_query($tr_1, "INSERT INTO test5 (i) VALUES (5)"); + +$res = ibase_query($tr_1, "SELECT * FROM test5"); + +echo "four rows\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_commit($tr_1); + +$res = ibase_query($tr_2, "SELECT * FROM test5"); + +echo "four rows again\n"; +out_result($res,"test5"); + +ibase_free_result($res); + +ibase_close($link_1); +ibase_close($link_2); - echo "end of test\n"; +echo "end of test\n"; ?> --EXPECT-- default transaction: http://cvs.php.net/diff.php/php-src/ext/interbase/tests/006.phpt?r1=1.2.4.3&r2=1.2.4.4&ty=u Index: php-src/ext/interbase/tests/006.phpt diff -u php-src/ext/interbase/tests/006.phpt:1.2.4.3 php-src/ext/interbase/tests/006.phpt:1.2.4.4 --- php-src/ext/interbase/tests/006.phpt:1.2.4.3 Wed Sep 3 18:07:31 2003 +++ php-src/ext/interbase/tests/006.phpt Sun Feb 15 15:47:21 2004 @@ -5,200 +5,196 @@ --POST-- --GET-- --FILE-- -<?php +<?php /* $Id: 006.phpt,v 1.2.4.4 2004/02/15 20:47:21 abies Exp $ */ - require("interbase.inc"); - - ibase_connect($test_base); - - ibase_query( - "create table test6 ( - iter integer, - v_char char(1000), - v_date timestamp, - v_decimal decimal(12,3), - v_double double precision, - v_float float, - v_integer integer, - v_numeric numeric(4,2), - v_smallint smallint, - v_varchar varchar(10000) - )"); - ibase_commit(); - - /* if timefmt not supported, hide error */ - @ibase_timefmt("%m/%d/%Y %H:%M:%S"); - - echo "insert\n"; - - for($iter = 0; $iter < 3; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal = rand_number(12,3); - $v_double = rand_number(20); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_numeric = rand_number(4,2); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - ibase_query("insert into test6 - (iter,v_char,v_date,v_decimal,v_double,v_float, - v_integer,v_numeric,v_smallint,v_varchar) - values (?,?,?,?,?,?,?,?,?,?)", - $iter, $v_char, $v_date, $v_decimal, $v_double, $v_float, - $v_integer, $v_numeric, $v_smallint, $v_varchar); - $sel = ibase_query("select * from test6 where iter = $iter"); - - $row = ibase_fetch_object($sel); - if(substr($row->V_CHAR,0,strlen($v_char)) != $v_char){ - echo " CHAR fail:\n"; - echo " in: $v_char\n"; - echo " out: $row->V_CHAR\n"; - } - if($row->V_DATE != $v_date){ - echo " DATE fail\n"; - echo " in: $v_date\n"; - echo " out: $row->V_DATE\n"; - } - if($row->V_DECIMAL != $v_decimal){ - echo " DECIMAL fail\n"; - echo " in: $v_decimal\n"; - echo " out: $row->V_DECIMAL\n"; - } - if(abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)){ - echo " DOUBLE fail\n"; - echo " in: $v_double\n"; - echo " out: $row->V_DOUBLE\n"; - } - if(abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)){ - echo " FLOAT fail\n"; - echo " in: $v_float\n"; - echo " out: $row->V_FLOAT\n"; - } - if($row->V_INTEGER != $v_integer){ - echo " INTEGER fail\n"; - echo " in: $v_integer\n"; - echo " out: $row->V_INTEGER\n"; - } - if ($row->V_NUMERIC != $v_numeric){ - echo " NUMERIC fail\n"; - echo " in: $v_numeric\n"; - echo " out: $row->V_NUMERIC\n"; - } - if ($row->V_SMALLINT != $v_smallint){ - echo " SMALLINT fail\n"; - echo " in: $v_smallint\n"; - echo " out: $row->V_SMALLINT\n"; - } - if ($row->V_VARCHAR != $v_varchar){ - echo " VARCHAR fail:\n"; - echo " in: $v_varchar\n"; - echo " out: $row->V_VARCHAR\n"; - } - ibase_free_result($sel); - }/* for($iter)*/ - - echo "select\n"; - for($iter = 0; $iter < 3; $iter++){ - /* prepare data */ - $v_char = rand_str(1000); - $v_date = rand_datetime(); - $v_decimal = rand_number(12,3); - $v_double = rand_number(20); - $v_float = rand_number(7); - $v_integer = rand_number(9,0); - $v_numeric = rand_number(4,2); - $v_smallint = rand_number(5) % 32767; - $v_varchar = rand_str(10000); - - /* clear table*/ - ibase_query("delete from test6"); - - /* make one record */ - ibase_query("insert into test6 - (iter, v_char,v_date,v_decimal, - v_integer,v_numeric,v_smallint,v_varchar) - values (666, '$v_char','$v_date',$v_decimal, $v_integer, - $v_numeric, $v_smallint, '$v_varchar')"); - - /* test all types */ - if(!($sel = ibase_query( - "select iter from test6 where v_char = ?", $v_char))) - echo "CHAR fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_date = ?", $v_date))) - echo "DATE fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_decimal = ?", $v_decimal))) - echo "DECIMAL fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_integer = ?", $v_integer))) - echo "INTEGER fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_numeric = ?", $v_numeric))) - echo "NUMERIC fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_smallint = ?", $v_smallint))) - echo "SMALLINT fail\n"; - ibase_free_result($sel); - if(!($sel = ibase_query( - "select iter from test6 where v_varchar = ?", $v_varchar))) - echo "VARCHAR fail\n"; - ibase_free_result($sel); - - }/*for iter*/ - - echo "prepare and exec insert\n"; - - /* prepare table */ - ibase_query("delete from test6"); - - /* prepare query */ - $query = ibase_prepare( - "insert into test6 (v_integer) values (?)"); - - for($i = 0; $i < 10; $i++) - ibase_execute($query, $i); - - out_table("test6"); - - ibase_free_query($query); - - - echo "prepare and exec select\n"; - - /* prepare query */ - $query = ibase_prepare("select * from test6 - where v_integer between ? and ?"); - - $low_border = 2; - $high_border = 6; - - $res = ibase_execute($query, $low_border, $high_border); - out_result($res, "test6"); - ibase_free_result($res); - - $low_border = 0; - $high_border = 4; - $res = ibase_execute($query, $low_border, $high_border); - out_result($res, "test6"); - ibase_free_result($res); - - $res = ibase_execute($query, "5", 7.5); - out_result($res, "test6"); - ibase_free_result($res); +require("interbase.inc"); - ibase_free_query($query); +ibase_connect($test_base); - ibase_close(); - echo "end of test\n"; +ibase_query( + "CREATE TABLE test6 ( + iter integer, + v_char char(1000), + v_date timestamp, + v_decimal decimal(12,3), + v_double double precision, + v_float float, + v_integer integer, + v_numeric numeric(4,2), + v_smallint smallint, + v_varchar varchar(10000) + )"); +ibase_commit(); + +/* if timefmt not supported, hide error */ +@ibase_timefmt("%m/%d/%Y %H:%M:%S"); + +echo "insert\n"; + +for ($iter = 0; $iter < 3; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal = rand_number(12,3); + $v_double = rand_number(20); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_numeric = rand_number(4,2); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + ibase_query("INSERT INTO test6 + (iter,v_char,v_date,v_decimal,v_double,v_float, v_integer, + v_numeric,v_smallint,v_varchar) VALUES (?,?,?,?,?,?,?,?,?,?)", + $iter, $v_char, $v_date, $v_decimal, $v_double, $v_float, + $v_integer, $v_numeric, $v_smallint, $v_varchar); + $sel = ibase_query("SELECT * FROM test6 WHERE iter = $iter"); + + $row = ibase_fetch_object($sel); + if (substr($row->V_CHAR,0,strlen($v_char)) != $v_char) { + echo " CHAR fail:\n"; + echo " in: $v_char\n"; + echo " out: $row->V_CHAR\n"; + } + if ($row->V_DATE != $v_date) { + echo " DATE fail\n"; + echo " in: $v_date\n"; + echo " out: $row->V_DATE\n"; + } + if ($row->V_DECIMAL != $v_decimal) { + echo " DECIMAL fail\n"; + echo " in: $v_decimal\n"; + echo " out: $row->V_DECIMAL\n"; + } + if (abs($row->V_DOUBLE - $v_double) > abs($v_double / 1E15)) { + echo " DOUBLE fail\n"; + echo " in: $v_double\n"; + echo " out: $row->V_DOUBLE\n"; + } + if (abs($row->V_FLOAT - $v_float) > abs($v_float / 1E7)) { + echo " FLOAT fail\n"; + echo " in: $v_float\n"; + echo " out: $row->V_FLOAT\n"; + } + if ($row->V_INTEGER != $v_integer) { + echo " INTEGER fail\n"; + echo " in: $v_integer\n"; + echo " out: $row->V_INTEGER\n"; + } + if ($row->V_NUMERIC != $v_numeric) { + echo " NUMERIC fail\n"; + echo " in: $v_numeric\n"; + echo " out: $row->V_NUMERIC\n"; + } + if ($row->V_SMALLINT != $v_smallint) { + echo " SMALLINT fail\n"; + echo " in: $v_smallint\n"; + echo " out: $row->V_SMALLINT\n"; + } + if ($row->V_VARCHAR != $v_varchar) { + echo " VARCHAR fail:\n"; + echo " in: $v_varchar\n"; + echo " out: $row->V_VARCHAR\n"; + } + ibase_free_result($sel); +} /* for($iter) */ + +echo "select\n"; +for ($iter = 0; $iter < 3; ++$iter) { + /* prepare data */ + $v_char = rand_str(1000); + $v_date = rand_datetime(); + $v_decimal = rand_number(12,3); + $v_double = rand_number(20); + $v_float = rand_number(7); + $v_integer = rand_number(9,0); + $v_numeric = rand_number(4,2); + $v_smallint = rand_number(5) % 32767; + $v_varchar = rand_str(10000); + + /* clear table*/ + ibase_query("DELETE FROM test6"); + + /* make one record */ + ibase_query("INSERT INTO test6 (iter, v_char,v_date,v_decimal,v_integer,v_numeric, + v_smallint,v_varchar) VALUES (666, '$v_char','$v_date',$v_decimal, $v_integer, + $v_numeric, $v_smallint, '$v_varchar')"); + + /* test all types */ + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_char = ?", $v_char))) + echo "CHAR fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_date = ?", $v_date))) + echo "DATE fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_decimal = ?", $v_decimal))) + echo "DECIMAL fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_integer = ?", $v_integer))) + echo "INTEGER fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_numeric = ?", $v_numeric))) + echo "NUMERIC fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_smallint = ?", $v_smallint))) + echo "SMALLINT fail\n"; + ibase_free_result($sel); + if (!($sel = ibase_query( + "SELECT iter FROM test6 WHERE v_varchar = ?", $v_varchar))) + echo "VARCHAR fail\n"; + ibase_free_result($sel); + +} /* for ($iter) */ + +echo "prepare and exec insert\n"; + +/* prepare table */ +ibase_query("DELETE FROM test6"); + +/* prepare query */ +$query = ibase_prepare( + "INSERT INTO test6 (v_integer) VALUES (?)"); + +for($i = 0; $i < 10; $i++) + ibase_execute($query, $i); + +out_table("test6"); + +ibase_free_query($query); + + +echo "prepare and exec select\n"; + +/* prepare query */ +$query = ibase_prepare("SELECT * FROM test6 WHERE v_integer BETWEEN ? AND ?"); + +$low_border = 2; +$high_border = 6; + +$res = ibase_execute($query, $low_border, $high_border); +out_result($res, "test6"); +ibase_free_result($res); + +$low_border = 0; +$high_border = 4; +$res = ibase_execute($query, $low_border, $high_border); +out_result($res, "test6"); +ibase_free_result($res); + +$res = ibase_execute($query, "5", 7.5); +out_result($res, "test6"); +ibase_free_result($res); + +ibase_free_query($query); + +ibase_close(); +echo "end of test\n"; ?> --EXPECT-- insert