Annotation of embedaddon/php/ext/oci8/tests/define3.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: Test oci_define_by_name() LOB descriptor
        !             3: --SKIPIF--
        !             4: <?php
        !             5: $target_dbs = array('oracledb' => true, 'timesten' => false);  // test runs on these DBs
        !             6: require(dirname(__FILE__).'/skipif.inc');
        !             7: ?> 
        !             8: --FILE--
        !             9: <?php
        !            10: 
        !            11: require(dirname(__FILE__)."/connect.inc");
        !            12: 
        !            13: $stmtarray = array(
        !            14:        "drop table phpdefblobtable",
        !            15:        "create table phpdefblobtable (id number(10), fileimage blob)"
        !            16: );
        !            17:                                                 
        !            18: oci8_test_sql_execute($c, $stmtarray);
        !            19: 
        !            20: // Load data
        !            21: $stmt = oci_parse ($c, "insert into phpdefblobtable (id, fileimage) values (:id, empty_blob()) returning fileimage into :fileimage");
        !            22: $fileimage = oci_new_descriptor($c,OCI_D_LOB);
        !            23: oci_bind_by_name($stmt,":id",$id);
        !            24: oci_bind_by_name($stmt,":fileimage",$fileimage,-1,OCI_B_BLOB);
        !            25: $id = 1;
        !            26: oci_execute($stmt, OCI_DEFAULT);
        !            27: $fileimage->savefile(dirname(__FILE__)."/test.gif");
        !            28: $data = $fileimage->load();
        !            29: var_dump(md5($data));  // original md5
        !            30: oci_commit($c);
        !            31: 
        !            32: // New row with different data
        !            33: $id = 2;
        !            34: $data = strrev($data);
        !            35: var_dump(md5($data));
        !            36: oci_execute($stmt, OCI_DEFAULT);
        !            37: $fileimage->save($data);
        !            38: oci_commit($c);
        !            39: 
        !            40: echo "Test 1\n";
        !            41: $stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
        !            42: var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $f));
        !            43: oci_execute($stmt);
        !            44: 
        !            45: while (oci_fetch($stmt)) {
        !            46:    var_dump($f);
        !            47:    echo "file md5:" . md5($f->load()) . "\n";
        !            48: }
        !            49: 
        !            50: echo "Test 2\n";
        !            51: $stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
        !            52: var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_STR));
        !            53: oci_execute($stmt);
        !            54: 
        !            55: while (oci_fetch($stmt)) {
        !            56:    echo "file md5:" . md5($outdata) . "\n";
        !            57: }
        !            58: 
        !            59: echo "Test 3\n";
        !            60: $stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
        !            61: var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $outdata, SQLT_BIN));
        !            62: oci_execute($stmt);
        !            63: 
        !            64: while (oci_fetch($stmt)) {
        !            65:    echo "file md5:" . md5($outdata) . "\n";
        !            66: }
        !            67: 
        !            68: echo "Test 4\n";
        !            69: $fid = oci_new_descriptor($c,OCI_D_LOB);
        !            70: $stmt = oci_parse($c, "SELECT fileimage FROM phpdefblobtable");
        !            71: var_dump(oci_define_by_name($stmt, 'FILEIMAGE', $fid));
        !            72: oci_execute($stmt);
        !            73: 
        !            74: while (oci_fetch($stmt)) {
        !            75:    echo "file md5:" . md5($fid->load()) . "\n";
        !            76: }
        !            77: 
        !            78: $stmtarray = array(
        !            79:        "drop table phpdefblobtable"
        !            80: );
        !            81:                                                 
        !            82: oci8_test_sql_execute($c, $stmtarray);
        !            83: 
        !            84: echo "Done\n";
        !            85: 
        !            86: ?>
        !            87: --EXPECTF--
        !            88: string(32) "614fcbba1effb7caa27ef0ef25c27fcf"
        !            89: string(32) "06d4f219d946c74d748d43932cd9dcb2"
        !            90: Test 1
        !            91: bool(true)
        !            92: object(OCI-Lob)#%d (1) {
        !            93:   ["descriptor"]=>
        !            94:   resource(%d) of type (oci8 descriptor)
        !            95: }
        !            96: file md5:614fcbba1effb7caa27ef0ef25c27fcf
        !            97: object(OCI-Lob)#%d (1) {
        !            98:   ["descriptor"]=>
        !            99:   resource(%d) of type (oci8 descriptor)
        !           100: }
        !           101: file md5:06d4f219d946c74d748d43932cd9dcb2
        !           102: Test 2
        !           103: bool(true)
        !           104: 
        !           105: Warning: oci_fetch(): ORA-00932: %s on line %d
        !           106: Test 3
        !           107: bool(true)
        !           108: file md5:614fcbba1effb7caa27ef0ef25c27fcf
        !           109: file md5:06d4f219d946c74d748d43932cd9dcb2
        !           110: Test 4
        !           111: bool(true)
        !           112: file md5:614fcbba1effb7caa27ef0ef25c27fcf
        !           113: file md5:06d4f219d946c74d748d43932cd9dcb2
        !           114: Done
        !           115: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>