当前位置: 首页>>代码示例>>PHP>>正文


PHP MySQLPDOTest::createTestTable方法代码示例

本文整理汇总了PHP中MySQLPDOTest::createTestTable方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLPDOTest::createTestTable方法的具体用法?PHP MySQLPDOTest::createTestTable怎么用?PHP MySQLPDOTest::createTestTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySQLPDOTest的用法示例。


在下文中一共展示了MySQLPDOTest::createTestTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pdo_mysql_errorinfo

function pdo_mysql_errorinfo($db, $offset)
{
    try {
        /*
        If you create a PDOStatement object through PDO->prepare()
        or PDO->query() and invoke an error on the statement handle,
        PDO->errorCode() will not reflect that error. You must call
        PDOStatement->errorCode() to return the error code for an
        operation performed on a particular statement handle.
        */
        $code = $db->errorCode();
        check_error($offset + 2, $db);
        $stmt = $db->query('SELECT id, label FROM test');
        $stmt2 =& $stmt;
        check_error($offset + 3, $db);
        check_error($offset + 4, $stmt);
        $db->exec('DROP TABLE IF EXISTS test');
        @$stmt->execute();
        check_error($offset + 5, $db);
        check_error($offset + 6, $stmt, '42S02');
        check_error($offset + 7, $stmt2, '42S02');
        @($stmt = $db->query('SELECT id, label FROM unknown'));
        check_error($offset + 8, $db, '42S02');
        MySQLPDOTest::createTestTable($db);
        $stmt = $db->query('SELECT id, label FROM test');
        check_error($offset + 9, $db);
        check_error($offset + 10, $stmt);
        $db2 =& $db;
        $db->exec('DROP TABLE IF EXISTS unknown');
        @$db->query('SELECT id, label FROM unknown');
        check_error($offset + 11, $db, '42S02');
        check_error($offset + 12, $db2, '42S02');
        check_error($offset + 13, $stmt);
        check_error($offset + 14, $stmt2);
        // lets hope this is an invalid attribute code
        $invalid_attr = -1 * PHP_INT_MAX + 3;
        $tmp = @$db->getAttribute($invalid_attr);
        check_error($offset + 15, $db, 'IM001');
        check_error($offset + 16, $db2, 'IM001');
        check_error($offset + 17, $stmt);
        check_error($offset + 18, $stmt2);
    } catch (PDOException $e) {
        printf("[%03d] %s [%s] %s\n", $offset + 19, $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
    }
}
开发者ID:badlamer,项目名称:hhvm,代码行数:45,代码来源:pdo_mysql_errorinfo.php

示例2: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
MySQLPDOTest::createTestTable($db);
function pdo_mysql_stmt_bindparam_types_do($db, $offset, $native, $sql_type, $value)
{
    if ($native) {
        $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 0);
    } else {
        $db->setAttribute(PDO::MYSQL_ATTR_DIRECT_QUERY, 1);
    }
    $db->exec('DROP TABLE IF EXISTS test');
    $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine());
    if (!($stmt = @$db->prepare($sql)) || !@$stmt->execute()) {
        // Server might not support column type - skip it
        return true;
    }
    $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (1, ?)');
    if (!$stmt->bindParam(1, $value)) {
        printf("[%03d/%s + 1] %s\n", $offset, $native ? 'native' : 'emulated', var_export($stmt->errorInfo(), true));
        return false;
    }
    if (!$stmt->execute()) {
        printf("[%03d/%s + 2] %s\n", $offset, $native ? 'native' : 'emulated', var_export($stmt->errorInfo(), true));
        return false;
    }
    $stmt = $db->query('SELECT id, label FROM test');
    $id = $label = null;
    if (!$stmt->bindColumn(1, $id)) {
        printf("[%03d/%s + 3] %s\n", $offset, $native ? 'native' : 'emulated', var_export($stmt->errorInfo(), true));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pdo_mysql_stmt_bindparam_types.php

示例3: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
function find_invalid_int($valid_options)
{
    do {
        $invalid = mt_rand(-10000, 10000);
    } while (in_array($invalid, $valid_options));
    return $invalid;
}
function set_and_get($offset, $db, $attribute, $value)
{
    $value_type = gettype($value);
    try {
        if (!$db->setAttribute($attribute, $value)) {
            printf("[%03d] Cannot set attribute '%s' to value '%s'\n", $offset, $attribute, var_export($tmp, true));
            return false;
        }
        if (gettype($value) != $value_type) {
            printf("[%03d] Call to PDO::setAttribute(int attribute, mixed value) has changed the type of value from %s to %s, test will not work properly\n", $offset, $value_type, gettype($value));
            return false;
        }
        $tmp = $db->getAttribute($attribute);
        if ($tmp !== $value) {
            printf("[%03d] Attribute '%s' was set to '%s'/%s but getAttribute() reports '%s'/%s\n", $offset, $attribute, var_export($value, true), gettype($value), var_export($tmp, true), gettype($tmp));
            return false;
        }
    } catch (PDOException $e) {
        printf("[%03d] %s, [%s] %s\n", $offset, $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pdo_mysql_get_attribute.php

示例4: test

    }
    $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
    if (true !== ($tmp = $db->commit())) {
        printf("[005] No commit allowed? [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
    }
    // a weak test without unicode etc. - lets leave that to dedicated tests
    $stmt = $db->query('SELECT id, label FROM test WHERE id = 100');
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (!isset($rows[0]['label']) || $rows[0]['label'] != 'z') {
        printf("[006] Record data is strange, dumping rows\n");
        var_dump($rows);
    }
    // Ok, lets check MyISAM resp. any other non-transactional engine
    // pdo_mysql_begin_transaction has more on this, quick check only
    $db = MySQLPDOTest::factory();
    MySQLPDOTest::createTestTable($db, 'MyISAM');
    if (true !== ($tmp = $db->beginTransaction())) {
        printf("[007] Expecting true, got %s/%s\n", gettype($tmp), $tmp);
    }
    $db->exec("INSERT INTO test(id, label) VALUES (100, 'z')");
    if (true !== ($tmp = $db->commit())) {
        printf("[008] No commit allowed? [%s] %s\n", $db->errorCode(), implode(' ', $db->errorInfo()));
    }
    // a weak test without unicode etc. - lets leave that to dedicated tests
    $stmt = $db->query('SELECT id, label FROM test WHERE id = 100');
    $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (!isset($rows[0]['label']) || $rows[0]['label'] != 'z') {
        printf("[009] Record data is strange, dumping rows\n");
        var_dump($rows);
    }
} catch (PDOException $e) {
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pdo_mysql_commit.php


注:本文中的MySQLPDOTest::createTestTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。