Annotation of embedaddon/php/ext/interbase/tests/004.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: InterBase: BLOB test
3: --SKIPIF--
4: <?php include("skipif.inc"); ?>
5: --FILE--
6: <?php /* $Id: 004.phpt 158958 2004-05-19 08:56:50Z helly $ */
7:
8: require("interbase.inc");
9:
10: $link = ibase_connect($test_base);
11:
12: ibase_query(
13: "CREATE TABLE test4 (
14: v_integer integer,
15: v_blob blob)");
16: ibase_commit();
17:
18: /* create 100k blob file */
19: $blob_str = rand_binstr(100*1024);
20:
21: $name = tempnam(dirname(__FILE__),"blob.tmp");
22: $ftmp = fopen($name,"w");
23: fwrite($ftmp,$blob_str);
24: fclose($ftmp);
25:
26: echo "import blob 1\n";
27: $ftmp = fopen($name,"r");
28: $bl_s = ibase_blob_import($ftmp);
29: ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (1, ?)", $bl_s);
30:
31: $bl_s = ibase_blob_import($link,$ftmp);
32: ibase_query($link, "INSERT INTO test4 (v_integer, v_blob) VALUES (1, ?)", $bl_s);
33: fclose($ftmp);
34:
35: echo "test blob 1\n";
36: $q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 1");
37:
38: $row = ibase_fetch_object($q);
39: $bl_h = ibase_blob_open($row->V_BLOB);
40:
41: $blob = '';
42: while($piece = ibase_blob_get($bl_h, 1 + rand() % 1024))
43: $blob .= $piece;
44: if($blob != $blob_str)
45: echo " BLOB 1 fail (1)\n";
46: ibase_blob_close($bl_h);
47:
48: $bl_h = ibase_blob_open($link,$row->V_BLOB);
49:
50: $blob = '';
51: while($piece = ibase_blob_get($bl_h, 100 * 1024))
52: $blob .= $piece;
53: if($blob != $blob_str)
54: echo " BLOB 1 fail (2)\n";
55: ibase_blob_close($bl_h);
56: ibase_free_result($q);
57: unset($blob);
58:
59: echo "create blob 2\n";
60:
61: ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (2, ?)", $blob_str);
62:
63: echo "test blob 2\n";
64:
65: $q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 2");
66: $row = ibase_fetch_object($q,IBASE_TEXT);
67:
68: if($row->V_BLOB != $blob_str)
69: echo " BLOB 2 fail\n";
70: ibase_free_result($q);
71: unset($blob);
72:
73:
74: echo "create blob 3\n";
75:
76: $bl_h = ibase_blob_create($link);
77:
78: ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
79: ibase_blob_add($bl_h, "| PHP HTML Embedded Scripting Language Version 3.0 |\n");
80: ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
81: ibase_blob_add($bl_h, "| Copyright (c) 1997-2000 PHP Development Team (See Credits file) |\n");
82: ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
83: ibase_blob_add($bl_h, "| This program is free software; you can redistribute it and/or modify |\n");
84: ibase_blob_add($bl_h, "| it under the terms of one of the following licenses: |\n");
85: ibase_blob_add($bl_h, "| |\n");
86: ibase_blob_add($bl_h, "| A) the GNU General Public License as published by the Free Software |\n");
87: ibase_blob_add($bl_h, "| Foundation; either version 2 of the License, or (at your option) |\n");
88: ibase_blob_add($bl_h, "| any later version. |\n");
89: ibase_blob_add($bl_h, "| |\n");
90: ibase_blob_add($bl_h, "| B) the PHP License as published by the PHP Development Team and |\n");
91: ibase_blob_add($bl_h, "| included in the distribution in the file: LICENSE |\n");
92: ibase_blob_add($bl_h, "| |\n");
93: ibase_blob_add($bl_h, "| This program is distributed in the hope that it will be useful, |\n");
94: ibase_blob_add($bl_h, "| but WITHOUT ANY WARRANTY; without even the implied warranty of |\n");
95: ibase_blob_add($bl_h, "| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |\n");
96: ibase_blob_add($bl_h, "| GNU General Public License for more details. |\n");
97: ibase_blob_add($bl_h, "| |\n");
98: ibase_blob_add($bl_h, "| You should have received a copy of both licenses referred to here. |\n");
99: ibase_blob_add($bl_h, "| If you did not, or have any questions about PHP licensing, please |\n");
100: ibase_blob_add($bl_h, "| contact core@php.net. |\n");
101: ibase_blob_add($bl_h, "+----------------------------------------------------------------------+\n");
102: $bl_s = ibase_blob_close($bl_h);
103: ibase_query("INSERT INTO test4 (v_integer, v_blob) VALUES (3, ?)", $bl_s);
104: ibase_commit();
105: echo "echo blob 3\n";
106:
107: $q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3");
108: $row = ibase_fetch_object($q);
109: ibase_commit();
110: ibase_close();
111:
112: ibase_connect($test_base);
113: ibase_blob_echo($link, $row->V_BLOB);
114: ibase_free_result($q);
115:
116: echo "fetch blob 3\n";
117: $q = ibase_query("SELECT v_blob FROM test4 WHERE v_integer = 3");
118: $row = ibase_fetch_object($q,IBASE_TEXT);
119: echo $row->V_BLOB;
120: ibase_free_result($q);
121:
122: ibase_close();
123: unlink($name);
124: echo "end of test\n";
125: ?>
126: --EXPECT--
127: import blob 1
128: test blob 1
129: create blob 2
130: test blob 2
131: create blob 3
132: echo blob 3
133: +----------------------------------------------------------------------+
134: | PHP HTML Embedded Scripting Language Version 3.0 |
135: +----------------------------------------------------------------------+
136: | Copyright (c) 1997-2000 PHP Development Team (See Credits file) |
137: +----------------------------------------------------------------------+
138: | This program is free software; you can redistribute it and/or modify |
139: | it under the terms of one of the following licenses: |
140: | |
141: | A) the GNU General Public License as published by the Free Software |
142: | Foundation; either version 2 of the License, or (at your option) |
143: | any later version. |
144: | |
145: | B) the PHP License as published by the PHP Development Team and |
146: | included in the distribution in the file: LICENSE |
147: | |
148: | This program is distributed in the hope that it will be useful, |
149: | but WITHOUT ANY WARRANTY; without even the implied warranty of |
150: | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
151: | GNU General Public License for more details. |
152: | |
153: | You should have received a copy of both licenses referred to here. |
154: | If you did not, or have any questions about PHP licensing, please |
155: | contact core@php.net. |
156: +----------------------------------------------------------------------+
157: fetch blob 3
158: +----------------------------------------------------------------------+
159: | PHP HTML Embedded Scripting Language Version 3.0 |
160: +----------------------------------------------------------------------+
161: | Copyright (c) 1997-2000 PHP Development Team (See Credits file) |
162: +----------------------------------------------------------------------+
163: | This program is free software; you can redistribute it and/or modify |
164: | it under the terms of one of the following licenses: |
165: | |
166: | A) the GNU General Public License as published by the Free Software |
167: | Foundation; either version 2 of the License, or (at your option) |
168: | any later version. |
169: | |
170: | B) the PHP License as published by the PHP Development Team and |
171: | included in the distribution in the file: LICENSE |
172: | |
173: | This program is distributed in the hope that it will be useful, |
174: | but WITHOUT ANY WARRANTY; without even the implied warranty of |
175: | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
176: | GNU General Public License for more details. |
177: | |
178: | You should have received a copy of both licenses referred to here. |
179: | If you did not, or have any questions about PHP licensing, please |
180: | contact core@php.net. |
181: +----------------------------------------------------------------------+
182: end of test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>