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

1.1     ! misho       1: --TEST--
        !             2: Test ROWID bind
        !             3: --SKIPIF--
        !             4: <?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
        !             5: --FILE--
        !             6: <?php
        !             7: 
        !             8: require(dirname(__FILE__)."/connect.inc");
        !             9: 
        !            10: function do_query($c)
        !            11: {
        !            12:        $s = oci_parse($c, 'select address from rid_tab order by id');
        !            13:        $id = 1;
        !            14:        oci_execute($s, OCI_DEFAULT);
        !            15:        while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) {
        !            16:                var_dump($row);
        !            17:        }
        !            18: }
        !            19: 
        !            20: $stmtarray = array(
        !            21:        "drop table rid_tab",
        !            22:        "create table rid_tab (id number, address varchar2(40))",
        !            23:        "insert into rid_tab (id, address) values (1, 'original text #1')",
        !            24:        "insert into rid_tab (id, address) values (2, 'original text #2')"
        !            25: );
        !            26: 
        !            27: oci8_test_sql_execute($c, $stmtarray);
        !            28: 
        !            29: echo "Initial Data\n";
        !            30: do_query($c);
        !            31: 
        !            32: $s = oci_parse($c, 'select rowid, address from rid_tab where id = :l_bv for update');
        !            33: $id = 1;
        !            34: oci_bind_by_name($s, ':l_bv', $id);
        !            35: oci_execute($s, OCI_DEFAULT);
        !            36: $row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS);
        !            37: 
        !            38: $rid = $row['ROWID'];
        !            39: $addr = $row['ADDRESS'];
        !            40: 
        !            41: $addr = 'Some new text';
        !            42: 
        !            43: // Save changes
        !            44: $s = oci_parse($c,'update rid_tab set address = :a_bv where rowid = :r_bv');
        !            45: oci_bind_by_name($s, ':r_bv', $rid, -1, OCI_B_ROWID);
        !            46: oci_bind_by_name($s, ':a_bv', $addr);
        !            47: oci_execute($s);
        !            48: 
        !            49: echo "Verify Change\n";
        !            50: do_query($c);
        !            51: 
        !            52: // Cleanup
        !            53: 
        !            54: $stmtarray = array(
        !            55:     "drop table rid_tab"
        !            56: );
        !            57: 
        !            58: oci8_test_sql_execute($c, $stmtarray);
        !            59: 
        !            60: echo "Done\n";
        !            61: 
        !            62: ?>
        !            63: --EXPECT--
        !            64: Initial Data
        !            65: array(1) {
        !            66:   ["ADDRESS"]=>
        !            67:   string(16) "original text #1"
        !            68: }
        !            69: array(1) {
        !            70:   ["ADDRESS"]=>
        !            71:   string(16) "original text #2"
        !            72: }
        !            73: Verify Change
        !            74: array(1) {
        !            75:   ["ADDRESS"]=>
        !            76:   string(13) "Some new text"
        !            77: }
        !            78: array(1) {
        !            79:   ["ADDRESS"]=>
        !            80:   string(16) "original text #2"
        !            81: }
        !            82: Done

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