mirror of
https://github.com/php/pecl-database-ibm_db2.git
synced 2026-03-23 23:02:16 +01:00
Mostly involved finding resources relative to the script directory instead of from the current directory, which make test sets as the source directory. Instead of writing a file and then reading it back in to compare, just build up a string in memory and compare them. Connecting to a missing db alias returns an empty SQLSTATE. I'm not sure if/when that changed, but I've adjusted the code to handle either case. Finally, escape.dat was missing a \r in the file.
39 lines
928 B
PHP
39 lines
928 B
PHP
--TEST--
|
|
IBM-DB2: db2_fetch_assoc() - fetch binary data and iterate over result set
|
|
--SKIPIF--
|
|
<?php require_once('skipif.inc'); ?>
|
|
--FILE--
|
|
<?php
|
|
|
|
require_once('connection.inc');
|
|
|
|
$conn = db2_connect($db,$username,$password);
|
|
|
|
$in_file = "pic1.jpg";
|
|
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
|
|
|
|
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='jpg' and empno='000130'");
|
|
$row = db2_fetch_assoc($result);
|
|
$out = "";
|
|
if ($row) {
|
|
$out .= $row['PICTURE'];
|
|
}
|
|
|
|
if(strcmp($in, $out) == 0) {
|
|
echo "The files are the same...good.";
|
|
} else {
|
|
echo "The files are not the same...bad.";
|
|
}
|
|
|
|
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo");
|
|
$count = 0;
|
|
while ($row = db2_fetch_assoc($result)) {
|
|
$count++;
|
|
}
|
|
|
|
echo "\nIterated over $count rows.";
|
|
?>
|
|
--EXPECT--
|
|
The files are the same...good.
|
|
Iterated over 8 rows.
|