Skip to content

Commit c5a0173

Browse files
author
Ambrish Bhargava
committed
Adding graphic data type test
1 parent 47ed55d commit c5a0173

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ Fix for connection rollback in db2_pconnect at the end of request.
258258
<file baseinstalldir="ibm_db2" name="test_10931_V6_LcaseTableName.phpt" role="test" />
259259
<file baseinstalldir="ibm_db2" name="test_clob_special_char.phpt" role="test" />
260260
<file baseinstalldir="ibm_db2" name="test_decfloat.phpt" role="test" />
261+
<file baseinstalldir="ibm_db2" name="test_graphic_data_type.phpt" role="test" />
261262
<file baseinstalldir="ibm_db2" name="test_last_insert_id.phpt" role="test" />
262263
<file baseinstalldir="ibm_db2" name="test_last_insert_id_V5V6.phpt" role="test" />
263264
<file baseinstalldir="ibm_db2" name="test_queryTimeout.phpt" role="test" />

tests/test_graphic_data_type.phpt

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
--TEST--
2+
IBM-DB2: Testing Graphic Datatype.
3+
--SKIPIF--
4+
<?php require_once('skipif.inc'); ?>
5+
--FILE--
6+
<?php
7+
8+
require_once('connection.inc');
9+
$conn = db2_connect($database, $user, $password);
10+
11+
if($conn) {
12+
echo "Connection created.\n";
13+
14+
/* Required SQls. */
15+
$sql_drop_table = "DROP TABLE test_graphic";
16+
$sql_create_table = "CREATE TABLE test_graphic (TEXT_F CHARACTER(20) NOT NULL, UNICODE GRAPHIC(20))";
17+
$sql_insert = "INSERT INTO test_graphic(TEXT_F, UNICODE) VALUES(?, ?)";
18+
$sql_select = "SELECT * FROM test_graphic";
19+
20+
/* Dropping table if exist. */
21+
@db2_exec($conn, $sql_drop_table);
22+
23+
/* Creating table. */
24+
$ret = db2_exec($conn, $sql_create_table);
25+
if(!$ret) {
26+
echo db2_stmt_errormsg() . "\n";
27+
}
28+
29+
$params = array(
30+
array('a', "Test_01"),
31+
array('b', "Test_02"),
32+
array('c', "Test_03"),
33+
array('d', "Test_04"),
34+
array('e', "Test_05")
35+
);
36+
37+
/* Prepare sql to insert data in table. */
38+
$stmt = db2_prepare($conn, $sql_insert);
39+
if(!$stmt) {
40+
echo db2_stmt_errormsg() . "\n";
41+
} else {
42+
foreach ($params as $param) {
43+
db2_execute($stmt, $param);
44+
}
45+
46+
$stmt = db2_exec($conn, $sql_select);
47+
if(!$stmt) {
48+
echo db2_stmt_errormsg() . "\n";
49+
} else {
50+
while ($row = db2_fetch_array($stmt)) {
51+
echo $row[0] . "|";
52+
echo $row[1] . "|";
53+
echo "\n";
54+
}
55+
}
56+
}
57+
58+
db2_close($conn);
59+
echo "Connection closed.";
60+
} else {
61+
echo "Connection Failed.\n";
62+
echo db2_conn_errormsg() . "\n";
63+
}
64+
?>
65+
--EXPECT--
66+
Connection created.
67+
a |Test_01 |
68+
b |Test_02 |
69+
c |Test_03 |
70+
d |Test_04 |
71+
e |Test_05 |
72+
Connection closed.

0 commit comments

Comments
 (0)