本文整理汇总了PHP中MySQLPDOTest::getDSN方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLPDOTest::getDSN方法的具体用法?PHP MySQLPDOTest::getDSN怎么用?PHP MySQLPDOTest::getDSN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLPDOTest
的用法示例。
在下文中一共展示了MySQLPDOTest::getDSN方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: try_buffer_size
function try_buffer_size($offset, $buffer_size)
{
try {
$dsn = MySQLPDOTest::getDSN();
$user = PDO_MYSQL_TEST_USER;
$pass = PDO_MYSQL_TEST_PASS;
/* unsigned overflow possible ? */
$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE => $buffer_size, PDO::MYSQL_ATTR_DIRECT_QUERY => 0, PDO::ATTR_EMULATE_PREPARES => 0));
$db->exec('DROP TABLE IF EXISTS test');
$db->exec(sprintf('CREATE TABLE test(id INT, val LONGBLOB) ENGINE = %s', PDO_MYSQL_TEST_ENGINE));
// 10 * (10 * 1024) = 10 * (10 * 1k) = 100k
$db->exec('INSERT INTO test(id, val) VALUES (1, REPEAT("01234567890", 10240))');
$stmt = $db->prepare('SELECT id, val FROM test');
$stmt->execute();
$id = $val = NULL;
$stmt->bindColumn(1, $id);
$stmt->bindColumn(2, $val);
while ($row = $stmt->fetch(PDO::FETCH_BOUND)) {
printf("[%03d] id = %d, val = %s... (length: %d)\n", $offset, $id, substr($val, 0, 10), strlen($val));
}
$db->exec('DROP TABLE IF EXISTS test');
} catch (PDOException $e) {
printf("[%03d] %s, [%s] %s\n", $offset, $e->getMessage(), is_object($db) ? $db->errorCode() : 'n/a', is_object($db) ? implode(' ', $db->errorInfo()) : 'n/a');
}
}
示例2: set_option_and_check
function set_option_and_check($offset, $option, $value, $option_desc, $ignore_diff = false)
{
$dsn = MySQLPDOTest::getDSN();
$user = PDO_MYSQL_TEST_USER;
$pass = PDO_MYSQL_TEST_PASS;
try {
$db = new PDO($dsn, $user, $pass, array($option => $value));
if (!is_object($db) || !$ignore_diff && $value !== ($tmp = @$db->getAttribute($option))) {
printf("[%03d] Execting '%s'/%s got '%s'/%s' for options '%s'\n", $offset, $value, gettype($value), $tmp, gettype($tmp), $option_desc);
}
} catch (PDOException $e) {
printf("[%03d] %s\n", $offset, $e->getMessage());
}
}
开发者ID:gleamingthecube,项目名称:php,代码行数:14,代码来源:ext_pdo_mysql_tests_pdo_mysql___construct_options_libmysql.php
示例3: dirname
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$dsn = MySQLPDOTest::getDSN();
$user = PDO_MYSQL_TEST_USER;
$pass = PDO_MYSQL_TEST_PASS;
$table = sprintf("test_%s", md5(mt_rand(0, PHP_INT_MAX)));
$db = new PDO($dsn, $user, $pass);
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
$create = sprintf('CREATE TABLE %s(id INT)', $table);
var_dump($create);
$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));
$info = $db->errorInfo();
var_dump($info[0]);
$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
print "done!";
示例4: empty
$have_latin2 = empty($tmp) ? false : true;
if ($have_latin1 && $have_latin2) {
// very likely we do have both of them...
try {
$dsn = MySQLPDOTest::getDSN(array('charset' => 'latin1'));
$db = new PDO($dsn, $user, $pass);
$stmt = $db->query('SELECT @@character_set_connection AS _charset');
$tmp = $stmt->fetch(PDO::FETCH_ASSOC);
if ($tmp['_charset'] != 'latin1') {
printf("[031] DSN = %s, Character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", $dsn, $tmp['_charset'], 'latin1');
}
} catch (PDOException $e) {
printf("[032] %s\n", $e->getMessage());
}
try {
$dsn = MySQLPDOTest::getDSN(array('charset' => 'latin2'));
$db = new PDO($dsn, $user, $pass);
$stmt = $db->query('SELECT @@character_set_connection AS _charset');
$tmp = $stmt->fetch(PDO::FETCH_ASSOC);
if ($tmp['_charset'] != 'latin2') {
printf("[033] DSN = %s, character sets has not been set, @@character_set_connection reports '%s', expecting '%s'", $dsn, $tmp['_charset'], 'latin2');
}
} catch (PDOException $e) {
printf("[034] %s\n", $e->getMessage());
}
}
}
} catch (PDOException $e) {
printf("[001] %s, [%s] %s\n", $e->getMessage(), is_object($db) ? $db->errorCode() : 'n/a', is_object($db) ? implode(' ', $db->errorInfo()) : 'n/a');
}
print "done!";
示例5: dirname
<?php
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc';
$found = false;
$values = ini_get_all();
foreach ($values as $name => $dsn) {
if ('pdo.dsn.mysql' == $name) {
printf("pdo.dsn.mysql=%s\n", $dsn);
$found = true;
break;
}
}
if (!$found) {
$dsn = ini_get('pdo.dsn.mysql');
$found = $dsn !== false;
}
if (!$found) {
printf("pdo.dsn.mysql cannot be accessed through ini_get_all()/ini_get()\n");
}
if (MySQLPDOTest::getDSN() == $dsn) {
// we are lucky, we can run the test
try {
$user = PDO_MYSQL_TEST_USER;
$pass = PDO_MYSQL_TEST_PASS;
$db = new PDO('mysql', $user, $pass);
} catch (PDOException $e) {
printf("[001] %s, [%s] %s\n", $e->getMessage(), is_object($db) ? $db->errorCode() : 'n/a', is_object($db) ? implode(' ', $db->errorInfo()) : 'n/a');
}
}
print "done!";