Annotation of embedaddon/php/ext/oci8/tests/lob_027.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: oci_lob_truncate()
                      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: require dirname(__FILE__).'/create_table.inc';
                     13: 
                     14: $ora_sql = "INSERT INTO
                     15:                        ".$schema.$table_name." (blob)
                     16:                       VALUES (empty_blob())
                     17:                       RETURNING
                     18:                                blob
                     19:                       INTO :v_blob ";
                     20: 
                     21: $statement = oci_parse($c,$ora_sql);
                     22: $blob = oci_new_descriptor($c,OCI_D_LOB);
                     23: oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
                     24: oci_execute($statement, OCI_DEFAULT);
                     25: 
                     26: var_dump($blob);
                     27: 
                     28: $str = "this is a biiiig faaat test string. why are you reading it, I wonder? =)";
                     29: var_dump($blob->write($str));
                     30: 
                     31: oci_commit($c);
                     32: 
                     33: $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
                     34: $s = oci_parse($c, $select_sql);
                     35: oci_execute($s, OCI_DEFAULT);
                     36: 
                     37: var_dump($row = oci_fetch_array($s));
                     38: oci_commit($c);
                     39: 
                     40: for ($i = 5; $i >= 0; $i--) {
                     41: 
                     42:        $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
                     43:        $s = oci_parse($c, $select_sql);
                     44:        oci_execute($s, OCI_DEFAULT);
                     45: 
                     46:        $row = oci_fetch_array($s);
                     47:        var_dump($row['BLOB']->load());
                     48:        var_dump($row['BLOB']->truncate(($i-1)*10));
                     49:        
                     50:        oci_commit($c);
                     51: }
                     52: 
                     53: $select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE";
                     54: $s = oci_parse($c, $select_sql);
                     55: oci_execute($s, OCI_DEFAULT);
                     56: 
                     57: $row = oci_fetch_array($s);
                     58: var_dump($row['BLOB']->load());
                     59: var_dump($row['BLOB']->truncate(-1));
                     60: var_dump($row['BLOB']->truncate(0));
                     61: 
                     62: oci_commit($c);
                     63: 
                     64: require dirname(__FILE__).'/drop_table.inc';
                     65: 
                     66: echo "Done\n";
                     67: 
                     68: ?>
                     69: --EXPECTF--
                     70: object(OCI-Lob)#%d (1) {
                     71:   ["descriptor"]=>
                     72:   resource(%d) of type (oci8 descriptor)
                     73: }
                     74: int(72)
                     75: array(2) {
                     76:   [0]=>
                     77:   object(OCI-Lob)#%d (1) {
                     78:     ["descriptor"]=>
                     79:     resource(%d) of type (oci8 descriptor)
                     80:   }
                     81:   ["BLOB"]=>
                     82:   object(OCI-Lob)#%d (1) {
                     83:     ["descriptor"]=>
                     84:     resource(%d) of type (oci8 descriptor)
                     85:   }
                     86: }
                     87: string(72) "this is a biiiig faaat test string. why are you reading it, I wonder? =)"
                     88: bool(true)
                     89: string(40) "this is a biiiig faaat test string. why "
                     90: bool(true)
                     91: string(30) "this is a biiiig faaat test st"
                     92: bool(true)
                     93: string(20) "this is a biiiig faa"
                     94: bool(true)
                     95: string(10) "this is a "
                     96: bool(true)
                     97: string(0) ""
                     98: 
                     99: Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d
                    100: bool(false)
                    101: string(0) ""
                    102: 
                    103: Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d
                    104: bool(false)
                    105: bool(true)
                    106: Done

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