Annotation of embedaddon/php/ext/pdo_mysql/tests/pdo_mysql_bit.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: MySQL PDO->exec(), BIT columns - remove after fix!
        !             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: if (MySQLPDOTest::isPDOMySQLnd())
        !             9:        die("skip Known bug - mysqlnd handles BIT incorrectly!");
        !            10: ?>
        !            11: --FILE--
        !            12: <?php
        !            13:        /* TODO: remove this test after fix and enable the BIT test in pdo_mysql_types.phpt again */
        !            14:        require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
        !            15: 
        !            16:        function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL) {
        !            17: 
        !            18:                $db->exec('DROP TABLE IF EXISTS test');
        !            19:                $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine());
        !            20:                @$db->exec($sql);
        !            21:                if ($db->errorCode() != 0) {
        !            22:                        // not all MySQL Server versions and/or engines might support the type
        !            23:                        return true;
        !            24:                }
        !            25: 
        !            26:                $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)');
        !            27:                $stmt->bindValue(1, $offset);
        !            28:                $stmt->bindValue(2, $value);
        !            29:                if (!$stmt->execute()) {
        !            30:                        printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true));
        !            31:                        return false;
        !            32:                }
        !            33:                $stmt = $db->query('SELECT  id, label FROM test');
        !            34:                $row = $stmt->fetch(PDO::FETCH_ASSOC);
        !            35:                var_dump($row);
        !            36:                var_dump($value);
        !            37: 
        !            38:                return true;
        !            39:        }
        !            40: 
        !            41:        $db = MySQLPDOTest::factory();
        !            42:        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        !            43:        $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
        !            44:        $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
        !            45: 
        !            46:        test_type($db, 20, 'BIT(8)', 1);
        !            47: 
        !            48:        echo "done!\n";
        !            49: ?>
        !            50: --CLEAN--
        !            51: <?php
        !            52: require dirname(__FILE__) . '/mysql_pdo_test.inc';
        !            53: $db = MySQLPDOTest::factory();
        !            54: $db->exec('DROP TABLE IF EXISTS test');
        !            55: ?>
        !            56: --EXPECTF--
        !            57: array(2) {
        !            58:   [%u|b%"id"]=>
        !            59:   %unicode|string%(2) "20"
        !            60:   [%u|b%"label"]=>
        !            61:   %unicode|string%(1) "1"
        !            62: }
        !            63: int(1)
        !            64: done!

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