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


PHP PDOTest类代码示例

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


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

示例1: dirname

<?php

require dirname(__FILE__) . '/config.inc';
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
setlocale(LC_ALL, "de", "de_DE", "de_DE.ISO8859-1", "de_DE.ISO_8859-1", "de_DE.UTF-8");
$db->exec('CREATE TABLE test(floatval DECIMAL(8,6))');
$db->exec('INSERT INTO test VALUES(2.34)');
$value = 4.56;
$stmt = $db->prepare('INSERT INTO test VALUES(?)');
$stmt->execute(array($value));
var_dump($db->query('SELECT * from test')->fetchAll(PDO::FETCH_ASSOC));
开发者ID:badlamer,项目名称:hhvm,代码行数:12,代码来源:bug_41698.php

示例2: putenv

<?php

if (getenv('REDIR_TEST_DIR') === false) {
    putenv('REDIR_TEST_DIR=' . dirname(__FILE__) . '/../../pdo/tests/');
}
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$db = PDOTest::factory();
$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(20))');
$db->exec('INSERT INTO test VALUES(1, \'A\', \'A2\')');
$db->exec('INSERT INTO test VALUES(2, \'A\', \'B2\')');
$select1 = $db->prepare('SELECT id, val, val2 FROM test');
$select2 = $db->prepare('SELECT val, val2 FROM test');
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN, 2));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE, 0));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE, 1));
$select1->execute();
var_dump($select1->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_UNIQUE, 2));
$select2->execute();
var_dump($select2->fetchAll(PDO::FETCH_COLUMN | PDO::FETCH_GROUP));
开发者ID:badlamer,项目名称:hhvm,代码行数:28,代码来源:pdo_015.php

示例3: __destruct

class PDODatabase extends PDO
{
    function __destruct()
    {
        echo __METHOD__ . "()\n";
    }
    function query($sql)
    {
        echo __METHOD__ . "()\n";
        $stmt = $this->prepare($sql, array(PDO::ATTR_STATEMENT_CLASS => array('PDOStatementx', array($this))));
        $stmt->setFetchMode(PDO::FETCH_ASSOC);
        $stmt->execute();
        return $stmt;
    }
}
$db = PDOTest::factory('PDODatabase');
var_dump(get_class($db));
$db->exec('CREATE TABLE test(id INT NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(16))');
$stmt = $db->prepare("INSERT INTO test VALUES(?, ?, ?)");
var_dump(get_class($stmt));
foreach ($data as $row) {
    $stmt->execute($row);
}
unset($stmt);
$stmt = $db->query('SELECT * FROM test');
var_dump(get_class($stmt));
var_dump(get_class($stmt->dbh));
foreach ($stmt as $obj) {
    var_dump($obj);
}
echo "===DONE===\n";
开发者ID:gleamingthecube,项目名称:php,代码行数:31,代码来源:ext_pdo_tests_pdo_026.php

示例4: putenv

<?php

if (getenv('REDIR_TEST_DIR') === false) {
    putenv('REDIR_TEST_DIR=' . dirname(__FILE__) . '/../../pdo/tests/');
}
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
$pdo = PDOTest::factory();
$pdo->exec("create table test (id integer primary key, n varchar(255))");
$pdo->exec("INSERT INTO test (id, n) VALUES (1, 'hi')");
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
$stmt = $pdo->prepare("SELECT * FROM test");
$stmt->execute();
var_dump($stmt->fetchAll());
if ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
    $type = "clob";
} else {
    if ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'firebird') {
        $type = 'BLOB SUB_TYPE TEXT';
    } else {
        $type = "text";
    }
}
$pdo->exec("create table test2 (id integer primary key, n {$type})");
$pdo->exec("INSERT INTO test2 (id, n) VALUES (1,'hi')");
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
$stmt = $pdo->prepare("SELECT * FROM test2");
$stmt->execute();
var_dump($stmt->fetchAll());
开发者ID:gleamingthecube,项目名称:php,代码行数:28,代码来源:ext_pdo_tests_bug_38253.php

示例5: selectRecords

            $this->outletSession->save($user);
        }
        $this->outletSession->flush(false);
        $this->outletSession->setAutoFlush(true);
    }
    protected function selectRecords($times)
    {
        // TODO: should we clear identity map after querying?
        for ($i = 0; $i < $times; $i++) {
            $this->outletSession->from('User')->find();
        }
    }
}
class User
{
    public $id;
    public $name;
    public function __construct($id = 0, $name = '')
    {
        $this->id = $id;
        $this->name = $name;
    }
}
include_once 'profiler.inc';
$prof = new Profiler(true, true, 'text');
//$prof = new Profiler(true, true, 'html', dirname(__FILE__).'/');
$runner = new PDOTest();
//$runner = new OutletTest();
$runner->setProfiler($prof);
$runner->run(1000);
$prof->printTimers(true);
开发者ID:jimmydivvy,项目名称:outlet-orm,代码行数:31,代码来源:performance.php


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