Annotation of embedaddon/php/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: PDOStatements and multi query
                      3: --SKIPIF--
                      4: <?php
                      5: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
                      6: require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
                      7: MySQLPDOTest::skip();
                      8: ?>
                      9: --FILE--
                     10: <?php
                     11:        require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
                     12: 
                     13:        function mysql_stmt_multiquery_wrong_usage($db) {
                     14: 
                     15:                $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1');
                     16:                var_dump($stmt->errorInfo());
                     17:                var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
                     18:                var_dump($stmt->errorInfo());
                     19: 
                     20:        }
                     21: 
                     22:        function mysql_stmt_multiquery_proper_usage($db) {
                     23: 
                     24:                $stmt = $db->query('SELECT label FROM test ORDER BY id ASC LIMIT 1; SELECT label FROM test ORDER BY id ASC LIMIT 1');
                     25:                do {
                     26:                        var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
                     27:                } while ($stmt->nextRowset());
                     28: 
                     29:        }
                     30: 
                     31:        try {
                     32: 
                     33:                printf("Emulated Prepared Statements...\n");
                     34:                $db = MySQLPDOTest::factory();
                     35:                MySQLPDOTest::createTestTable($db);
                     36:                $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
                     37:                mysql_stmt_multiquery_wrong_usage($db);
                     38:                mysql_stmt_multiquery_proper_usage($db);
                     39: 
                     40:                printf("Native Prepared Statements...\n");
                     41:                $db = MySQLPDOTest::factory();
                     42:                MySQLPDOTest::createTestTable($db);
                     43:                $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
                     44:                mysql_stmt_multiquery_wrong_usage($db);
                     45:                mysql_stmt_multiquery_proper_usage($db);
                     46: 
                     47:        } catch (PDOException $e) {
                     48:                printf("[001] %s [%s] %s\n",
                     49:                        $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
                     50:        }
                     51: 
                     52:        print "done!";
                     53: ?>
                     54: --CLEAN--
                     55: <?php
                     56: require dirname(__FILE__) . '/mysql_pdo_test.inc';
                     57: MySQLPDOTest::dropTestTable();
                     58: ?>
                     59: --EXPECTF--
                     60: Emulated Prepared Statements...
                     61: array(3) {
                     62:   [0]=>
                     63:   %unicode|string%(5) "00000"
                     64:   [1]=>
                     65:   NULL
                     66:   [2]=>
                     67:   NULL
                     68: }
                     69: array(1) {
                     70:   [0]=>
                     71:   array(1) {
                     72:     [%u|b%"label"]=>
                     73:     %unicode|string%(1) "a"
                     74:   }
                     75: }
                     76: array(3) {
                     77:   [0]=>
                     78:   %unicode|string%(5) "00000"
                     79:   [1]=>
                     80:   NULL
                     81:   [2]=>
                     82:   NULL
                     83: }
                     84: array(1) {
                     85:   [0]=>
                     86:   array(1) {
                     87:     [%u|b%"label"]=>
                     88:     %unicode|string%(1) "a"
                     89:   }
                     90: }
                     91: array(1) {
                     92:   [0]=>
                     93:   array(1) {
                     94:     [%u|b%"label"]=>
                     95:     %unicode|string%(1) "a"
                     96:   }
                     97: }
                     98: Native Prepared Statements...
                     99: 
                    100: Warning: PDO::query(): SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%SSELECT label FROM test ORDER BY id ASC LIMIT 1' at line %d in %s on line %d
                    101: 
                    102: Fatal error: Call to a member function errorInfo() on a non-object in %s on line %d

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