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


PHP MySQLPDOTest::getTempDir方法代码示例

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


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

示例1: dirname

    }
    return true;
}
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
putenv('PDOTEST_ATTR=' . serialize([PDO::MYSQL_ATTR_LOCAL_INFILE => true]));
$db = MySQLPDOTest::factory();
MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db));
/* affected rows related */
try {
    exec_and_count(2, $db, 'DROP TABLE IF EXISTS test', 0);
    exec_and_count(3, $db, sprintf('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, col1 CHAR(10)) ENGINE=%s', PDO_MYSQL_TEST_ENGINE), 0);
    $stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
    if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && $row['value'] != '') {
        $filename = $row['value'] . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
    } else {
        $filename = MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . "pdo_mysql_exec_load_data.csv";
    }
    $fp = fopen($filename, "w");
    fwrite($fp, "1;foo\n");
    fwrite($fp, "2;bar");
    fclose($fp);
    $sql = sprintf("LOAD DATA LOCAL INFILE %s INTO TABLE test FIELDS TERMINATED BY ';' LINES TERMINATED  BY '\n'", $db->quote($filename));
    if (exec_and_count(4, $db, $sql, 2)) {
        $stmt = $db->query('SELECT id, col1 FROM test ORDER BY id ASC');
        $expected = array(array("id" => 1, "col1" => "foo"), array("id" => 2, "col1" => "bar"));
        $ret = $stmt->fetchAll(PDO::FETCH_ASSOC);
        foreach ($expected as $offset => $exp) {
            foreach ($exp as $key => $value) {
                if ($ret[$offset][$key] != $value) {
                    printf("Results seem wrong, check manually\n");
                    var_dump($ret);
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_pdo_mysql_tests_pdo_mysql_exec_load_data.php

示例2: dirname

<?php

require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
try {
    if ($tmp = MySQLPDOTest::getTempDir()) {
        $file = $tmp . DIRECTORY_SEPARATOR . 'pdomuri.tst';
        $dsn = MySQLPDOTest::getDSN();
        $user = PDO_MYSQL_TEST_USER;
        $pass = PDO_MYSQL_TEST_PASS;
        $uri = sprintf('uri:file:%s', $file);
        if ($fp = @fopen($file, 'w')) {
            // ok, great we can create a file with a DSN in it
            fwrite($fp, $dsn);
            fclose($fp);
            clearstatcache();
            assert(file_exists($file));
            try {
                $db = new PDO($uri, $user, $pass);
            } catch (PDOException $e) {
                printf("[002] URI=%s, DSN=%s, File=%s (%d bytes, '%s'), %s\n", $uri, $dsn, $file, filesize($file), file_get_contents($file), $e->getMessage());
            }
            unlink($file);
        }
        if ($fp = @fopen($file, 'w')) {
            fwrite($fp, sprintf('mysql:dbname=letshopeinvalid;%s%s', chr(0), $dsn));
            fclose($fp);
            clearstatcache();
            assert(file_exists($file));
            try {
                $db = new PDO($uri, $user, $pass);
            } catch (PDOException $e) {
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_pdo_mysql_tests_pdo_mysql___construct_uri.php

示例3: printf

    }
    $stmt2 = $db->query('SELECT id, label FROM test WHERE id = 1');
    $row = $stmt2->fetch(PDO::FETCH_ASSOC);
    if ($row['label'] != $blob) {
        printf("[%03d + 10] INSERT and/or SELECT has failed, dumping data.\n", $offset);
        var_dump($row);
        var_dump($blob);
        return false;
    }
    return true;
}
$db = MySQLPDOTest::factory();
$blob = 'I am a mighty BLOB!' . chr(0) . "I am a binary thingie!";
$tmp = MySQLPDOTest::getTempDir();
$file = $tmp . DIRECTORY_SEPARATOR . 'pdoblob.tst';
try {
    printf("Emulated PS...\n");
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1);
    blob_from_stream(10, $db, $file, $blob);
    printf("Native PS...\n");
    $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
    blob_from_stream(30, $db, $file, $blob);
} catch (PDOException $e) {
    printf("[001] %s [%s] %s\n", $e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
}
print "done!";
require dirname(__FILE__) . '/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec('DROP TABLE IF EXISTS test');
@unlink(MySQLPDOTest::getTempDir() . DIRECTORY_SEPARATOR . 'pdoblob.tst');
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:pdo_mysql_stmt_blobfromsteam.php


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