Annotation of embedaddon/php/ext/pdo/tests/bug_34630.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: PDO Common: Bug #34630 (inserting streams as LOBs)
                      3: --SKIPIF--
                      4: <?php # vim:ft=php
                      5: if (!extension_loaded('pdo')) die('skip');
                      6: $dir = getenv('REDIR_TEST_DIR');
                      7: if (false == $dir) die('skip no driver');
                      8: require_once $dir . 'pdo_test.inc';
                      9: PDOTest::skip();
                     10: ?>
                     11: --FILE--
                     12: <?php
                     13: if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
                     14: require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
                     15: $db = PDOTest::factory();
                     16: 
                     17: $driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
                     18: $is_oci = $driver == 'oci';
                     19: 
                     20: if ($is_oci) {
                     21:        $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val BLOB)');
                     22: } else {
                     23:        $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(256))');
                     24: }
                     25: $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                     26: 
                     27: $fp = tmpfile();
                     28: fwrite($fp, "I am the LOB data");
                     29: rewind($fp);
                     30: 
                     31: if ($is_oci) {
                     32:        /* oracle is a bit different; you need to initiate a transaction otherwise
                     33:         * the empty blob will be committed implicitly when the statement is
                     34:         * executed */
                     35:        $db->beginTransaction();
                     36:        $insert = $db->prepare("insert into test (id, val) values (1, EMPTY_BLOB()) RETURNING val INTO :blob");
                     37: } else {
                     38:        $insert = $db->prepare("insert into test (id, val) values (1, :blob)");
                     39: }
                     40: $insert->bindValue(':blob', $fp, PDO::PARAM_LOB);
                     41: $insert->execute();
                     42: $insert = null;
                     43: 
                     44: $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
                     45: var_dump($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC));
                     46: 
                     47: ?>
                     48: --EXPECT--
                     49: array(1) {
                     50:   [0]=>
                     51:   array(2) {
                     52:     ["id"]=>
                     53:     string(1) "1"
                     54:     ["val"]=>
                     55:     string(17) "I am the LOB data"
                     56:   }
                     57: }

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