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


PHP MySQLPDOTest::factory方法代码示例

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


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

示例1: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
function fetch($offset, &$db, $query, $expect = null)
{
    try {
        $stmt = $db->query('SELECT 1');
        $num = $stmt->fetch(PDO::FETCH_NUM);
        $stmt = $db->query('SELECT 1');
        $assoc = $stmt->fetch(PDO::FETCH_ASSOC);
        $stmt = $db->query('SELECT 1');
        $both = $stmt->fetch(PDO::FETCH_BOTH);
        $computed_both = array_merge($num, $assoc);
        if ($computed_both != $both) {
            printf("[%03d] Suspicious FETCH_BOTH result, dumping\n", $offset);
            var_dump($computed_both);
            var_dump($both);
        }
        if (!is_null($expect) && $expect != $both) {
            printf("[%03d] Expected differs from returned data, dumping\n", $offset);
            var_dump($expect);
            var_dump($both);
        }
    } catch (PDOException $e) {
        printf("[%03d] %s, [%s] %s\n", $offset, $e->getMessage(), $db->errroCode(), implode(' ', $db->errorInfo()));
    }
}
try {
    fetch(2, $db, 'SELECT 1', array(0 => '1', '1' => '1'));
} catch (PDOException $e) {
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pdo_mysql_fetch_both.php

示例2: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$pdo = MySQLPDOTest::factory();
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
$attrs = array(PDO::ATTR_EMULATE_PREPARES => array(null, 1, 0), PDO::MYSQL_ATTR_DIRECT_QUERY => array(null, 0, 1), PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => array(null, 0, 1), PDO::ATTR_AUTOCOMMIT => array(null), PDO::ATTR_PREFETCH => array(null), PDO::ATTR_TIMEOUT => array(null), PDO::ATTR_ERRMODE => array(null), PDO::ATTR_SERVER_VERSION => array(null), PDO::ATTR_CLIENT_VERSION => array(null), PDO::ATTR_SERVER_INFO => array(null), PDO::ATTR_CONNECTION_STATUS => array(null), PDO::ATTR_CASE => array(null), PDO::ATTR_CURSOR_NAME => array(null), PDO::ATTR_CURSOR => array(null), PDO::ATTR_ORACLE_NULLS => array(null), PDO::ATTR_PERSISTENT => array(null), PDO::ATTR_STATEMENT_CLASS => array(null), PDO::ATTR_FETCH_TABLE_NAMES => array(null), PDO::ATTR_FETCH_CATALOG_NAMES => array(null), PDO::ATTR_DRIVER_NAME => array(null), PDO::ATTR_STRINGIFY_FETCHES => array(null), PDO::ATTR_MAX_COLUMN_LEN => array(null), PDO::ATTR_DEFAULT_FETCH_MODE => array(null));
foreach ($attrs as $a => $vals) {
    foreach ($vals as $v) {
        try {
            if (!isset($v)) {
                var_dump($pdo->getAttribute($a));
            } else {
                $pdo->setAttribute($a, $v);
                if ($pdo->getAttribute($a) === $v) {
                    echo "OK\n";
                } else {
                    throw new \Exception('KO');
                }
            }
        } catch (\Exception $e) {
            if ($e->getCode() == 'IM001') {
                echo "ERR\n";
            } else {
                echo "ERR {$e->getMessage()}\n";
            }
        }
    }
}
开发者ID:gleamingthecube,项目名称:php,代码行数:28,代码来源:ext_pdo_mysql_tests_bug68371.php

示例3: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
/* Connect to mysql to determine the current charset so we can diffinate it */
$link = MySQLPDOTest::factory();
$charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value;
/* Make sure that we don't attempt to set the current character set to make this case useful */
$new_charset = $charset == 'latin1' ? 'ascii' : 'latin1';
/* Done with the original connection, create a second link to test the character set being defined */
unset($link);
$link = MySQLPDOTest::factory('PDO', false, null, array('charset' => $new_charset));
$conn_charset = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value;
if ($charset !== $conn_charset) {
    echo "done!\n";
} else {
    echo "failed!\n";
}
开发者ID:badlamer,项目名称:hhvm,代码行数:17,代码来源:pdo_mysql_connect_charset.php

示例4: dirname

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$expected = array('MYSQL_ATTR_USE_BUFFERED_QUERY' => true, 'MYSQL_ATTR_LOCAL_INFILE' => true, 'MYSQL_ATTR_DIRECT_QUERY' => true, 'MYSQL_ATTR_FOUND_ROWS' => true, 'MYSQL_ATTR_IGNORE_SPACE' => true, 'MYSQL_ATTR_INIT_COMMAND' => true, "MYSQL_ATTR_SSL_KEY" => true, "MYSQL_ATTR_SSL_CERT" => true, "MYSQL_ATTR_SSL_CA" => true, "MYSQL_ATTR_SSL_CAPATH" => true, "MYSQL_ATTR_SSL_CIPHER" => true, "MYSQL_ATTR_COMPRESS" => true);
if (!MySQLPDOTest::isPDOMySQLnd()) {
    $expected['MYSQL_ATTR_MAX_BUFFER_SIZE'] = true;
    $expected['MYSQL_ATTR_READ_DEFAULT_FILE'] = true;
    $expected['MYSQL_ATTR_READ_DEFAULT_GROUP'] = true;
}
if (extension_loaded('mysqlnd')) {
    $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true;
} else {
    if (extension_loaded('mysqli')) {
        if (mysqli_get_client_version() > 50605) {
            $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true;
        }
    } else {
        if (MySQLPDOTest::getClientVersion(MySQLPDOTest::factory()) > 50605) {
            /* XXX the MySQL client library version isn't exposed with any 
            		constants, the single possibility is to use the PDO::getAttribute().
            		This however will fail with no connection. */
            $expected['MYSQL_ATTR_SERVER_PUBLIC_KEY'] = true;
        }
    }
}
/*
TODO

	MYSQLI_OPT_CONNECT_TIMEOUT != PDO::ATTR_TIMEOUT  (integer)
    Sets the timeout value in seconds for communications with the database.
	^  Potential BUG, PDO::ATTR_TIMEOUT is used in pdo_mysql_handle_factory

	MYSQLI_SET_CHARSET_NAME -> DSN/charset=<charset_name>
开发者ID:badlamer,项目名称:hhvm,代码行数:31,代码来源:pdo_mysql_class_constants.php


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