php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #39199
Patch pdo_oci_stream_1.phpt revision 2010-12-09 02:58 UTC by yes at example dot com
Patch pdo_oci_fread_1.phpt revision 2010-12-09 02:56 UTC by yes at example dot com
Patch pdo_oci_stream_1.php revision 2010-12-07 07:44 UTC by yes at example dot com
Patch oci_statement.c.diff revision 2010-12-07 07:42 UTC by yes at example dot com

Patch pdo_oci_stream_1.php for PDO related Bug #39199

Patch version 2010-12-07 07:44 UTC

Return to Bug #39199 | Download this patch
This patch is obsolete

Obsoleted by patches:

Patch Revisions:

Developer: yes@example.com

--TEST--
PDO_OCI: stream_get_contents length & offset test
--SKIPIF--
<?php
if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
require(dirname(__FILE__).'/../../pdo/tests/pdo_test.inc');
PDOTest::skip();
?>
--FILE--
<?php

require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc');

$dbh = PDOTest::factory();

$dbh->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);

// Initialization
@$dbh->exec("drop table pdo_oci_stream_1_tab");

$stmtarray = array(
	"create table pdo_oci_stream_1_tab (id number, data clob)",
);

foreach ($stmtarray as $stmt) {
	$dbh->exec($stmt);
}

$dbh->exec("
  declare
    lob1 clob := 'abc' || lpad('j',30000,'j') || 'xyz';
   begin
    insert into pdo_oci_stream_1_tab (id,data) values (1, 'abcdefghijklmnopqrstuvwxyz');
    insert into pdo_oci_stream_1_tab (id,data) values (2, lob1);
  end;");

echo "Test 1\n";

$s = $dbh->prepare("select data from pdo_oci_stream_1_tab where id = 1");
$s->execute();
$r = $s->fetch();

// stream_get_contents ( resource $handle [, int $maxlength = -1 [, int $offset = -1 ]] )
echo 'Read '.stream_get_contents($r['data'], 1, 1)."$\n";  // b
echo 'Read '.stream_get_contents($r['data'], 2, 1)."$\n";  // cd
echo 'Read '.stream_get_contents($r['data'], 2, 0)."$\n";  // ab
echo 'Read '.stream_get_contents($r['data'], 26, 0)."$\n"; // abcdefghijklmnopqrstuvwxyz
echo 'Read '.stream_get_contents($r['data'], 27, 0)."$\n"; // abcdefghijklmnopqrstuvwxyz
echo 'Read '.stream_get_contents($r['data'], 27, 1)."$\n"; // bcdefghijklmnopqrstuvwxyz
echo 'Read '.stream_get_contents($r['data'], 1, 20)."$\n"; // u
echo 'Read '.stream_get_contents($r['data'], 1, 25)."$\n"; // z
echo 'Read '.stream_get_contents($r['data'], 1, 26)."$\n"; // <blank>
echo 'Read '.stream_get_contents($r['data'], 1, 0)."$\n";  // a

echo "\nTest 2\n";

$s = $dbh->prepare("select data from pdo_oci_stream_1_tab where id = 2");
$s->execute();
$r = $s->fetch();

echo 'Read '.stream_get_contents($r['data'], 5, 0)."\n";           // abcjj
echo 'Read '.stream_get_contents($r['data'], 5, 2)."\n";           // cjjjj
echo 'Read '.stream_get_contents($r['data'], 6, 1)."\n";           // bcjjjj
echo 'Read '.strlen(stream_get_contents($r['data'], -1,0))."\n";   // 30006
echo 'Read '.strlen(stream_get_contents($r['data'], 0,0))."\n";    // 0
echo 'Read '.strlen(stream_get_contents($r['data'], 0,1))."\n";    // 0
echo 'Read '.strlen(stream_get_contents($r['data'], 10,100))."\n"; // 10
echo 'Read '.stream_get_contents($r['data'], 6, 30000)."\n";       // jjjxyz
echo 'Read '.stream_get_contents($r['data'], 7, 30000)."\n";       // jjjxyz
echo 'Read '.strlen(stream_get_contents($r['data']))."\n";         // 0
echo 'Read '.strlen(stream_get_contents($r['data'], 0))."\n";      // 0
echo 'Read '.strlen(stream_get_contents($r['data'], -1))."\n";     // 0
echo 'Read '.stream_get_contents($r['data'], -1, 30000)."\n";      // jjjxyz

// Clean up

$stmtarray = array(
	"drop table pdo_oci_stream_1_tab"
);

foreach ($stmtarray as $stmt) {
	$dbh->exec($stmt);
}

?>
--EXPECTF--
Test 1
Read b$
Read cd$
Read ab$
Read abcdefghijklmnopqrstuvwxyz$
Read abcdefghijklmnopqrstuvwxyz$
Read bcdefghijklmnopqrstuvwxyz$
Read u$
Read z$
Read $
Read a$

Test 2
Read abcjj
Read cjjjj
Read bcjjjj
Read 30006
Read 0
Read 0
Read 10
Read jjjxyz
Read jjjxyz
Read 0
Read 0
Read 0
Read jjjxyz
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 09:02:29 2014 UTC