本文整理汇总了PHP中MySQLPDOTest::isPDOMySQLnd方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLPDOTest::isPDOMySQLnd方法的具体用法?PHP MySQLPDOTest::isPDOMySQLnd怎么用?PHP MySQLPDOTest::isPDOMySQLnd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLPDOTest
的用法示例。
在下文中一共展示了MySQLPDOTest::isPDOMySQLnd方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepex
if (count(($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC))) != 2)
printf("[074] Expecting two rows, got %d rows\n", $tmp);
*/
}
prepex(57, $db, 'DELETE FROM test');
prepex(58, $db, 'INSERT INTO test(id, label) VALUES (1, ?), (2, ?)', array('row1', 'row2'));
/*
TODO enable after fix
$stmt = prepex(37, $db, 'SELECT id, label FROM \'test WHERE MATCH label AGAINST (:placeholder)',
array(':placeholder' => 'row'),
array('execute' => array('sqlstate' => '42000', 'mysql' => 1064)));
*/
$stmt = prepex(59, $db, 'SELECT id, label AS "label" FROM test WHERE label = ?', array('row1'));
$tmp = $stmt->fetchAll(PDO::FETCH_ASSOC);
$exp = array(0 => array("id" => "1", "label" => "row1"));
if (MySQLPDOTest::isPDOMySQLnd()) {
// mysqlnd returns native types
$exp[0]['id'] = 1;
}
if ($tmp !== $exp) {
printf("[065] Results seem wrong. Please check dumps manually.\n");
var_dump($exp);
var_dump($tmp);
}
$sql = sprintf("SELECT id, label FROM test WHERE (label LIKE %s) AND (id = ?)", $db->quote('%ro%'));
$stmt = prepex(60, $db, $sql, array(-1));
if (count($tmp = $stmt->fetchAll(PDO::FETCH_ASSOC)) != 0) {
printf("[061] Expecting zero rows, got %d rows\n", $tmp);
}
$sql = sprintf("SELECT id, label FROM test WHERE (id = ?) OR (label LIKE %s)", $db->quote('%ro%'));
$stmt = prepex(61, $db, $sql, array(1));
示例2: printf
printf("[%03d + 6] Expecting native type %s, %s\n", $offset, var_export($native_type, true), var_export($meta, true));
return false;
}
}
if (!is_null($pdo_type) && $meta['pdo_type'] != $pdo_type) {
printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, $pdo_type, var_export($meta, true), var_export($meta['native_type']));
return false;
}
return true;
}
$stmt = $db->prepare('SELECT @@sql_mode AS _mode');
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$real_as_float = false === stristr($row['_mode'], "REAL_AS_FLOAT") ? false : true;
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$is_mysqlnd = MySQLPDOTest::isPDOMySQLnd();
test_meta($db, 20, 'BIT(8)', 1, 'BIT', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 30, 'TINYINT', -127, 'TINY', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 40, 'TINYINT UNSIGNED', 255, 'TINY', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 50, 'BOOLEAN', 1, NULL, $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 60, 'SMALLINT', -32768, 'SHORT', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 70, 'SMALLINT UNSIGNED', 65535, 'SHORT', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 80, 'MEDIUMINT', -8388608, 'INT24', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 90, 'MEDIUMINT UNSIGNED', 16777215, 'INT24', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 100, 'INT', -2147483648, 'LONG', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 110, 'INT UNSIGNED', 4294967295, 'LONG', $is_mysqlnd ? PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 120, 'BIGINT', -9.223372036854776E+18, 'LONGLONG', $is_mysqlnd ? PHP_INT_SIZE == 4 ? PDO::PARAM_STR : PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 130, 'BIGINT UNSIGNED', 1.8446744073709552E+19, 'LONGLONG', $is_mysqlnd ? PHP_INT_SIZE == 4 ? PDO::PARAM_STR : PDO::PARAM_INT : PDO::PARAM_STR);
test_meta($db, 130, 'REAL', -1.01, $real_as_float ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
test_meta($db, 140, 'REAL UNSIGNED', 1.01, $real_as_float ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
test_meta($db, 150, 'REAL ZEROFILL', -1.01, $real_as_float ? 'FLOAT' : 'DOUBLE', PDO::PARAM_STR);
示例3: pdo_mysql_stmt_closecursor
function pdo_mysql_stmt_closecursor($db)
{
// This one should fail. I let it fail to prove that closeCursor() makes a difference.
// If no error messages gets printed do not know if proper usage of closeCursor() makes any
// difference or not. That's why we need to cause an error here.
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
$stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
// query() shall fail!
$stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
$stmt1->closeCursor();
// This is proper usage of closeCursor(). It shall prevent any further error messages.
if (MySQLPDOTest::isPDOMySQLnd()) {
$stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
} else {
// see pdo_mysql_stmt_unbuffered_2050.phpt for an explanation
unset($stmt1);
$stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
}
// fetch only the first rows and let closeCursor() clean up
$row1 = $stmt1->fetch(PDO::FETCH_ASSOC);
$stmt1->closeCursor();
$stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?');
$stmt2->bindValue(1, "z");
$stmt2->bindValue(2, $row1['id']);
$stmt2->execute();
$stmt2->closeCursor();
$db->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
// check if changing the fetch mode from unbuffered to buffered will
// cause any harm to a statement created prior to the change
$stmt1->execute();
$row2 = $stmt1->fetch(PDO::FETCH_ASSOC);
$stmt1->closeCursor();
if (!isset($row2['label']) || 'z' !== $row2['label']) {
printf("Expecting array(id => 1, label => z) got %s\n", var_export($row2, true));
}
unset($stmt1);
$stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
// should work
$stmt2 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
$stmt1->closeCursor();
$stmt1 = $db->query('SELECT id, label FROM test ORDER BY id ASC');
// fetch only the first rows and let closeCursor() clean up
$row3 = $stmt1->fetch(PDO::FETCH_ASSOC);
$stmt1->closeCursor();
assert($row3 == $row2);
$stmt2 = $db->prepare('UPDATE test SET label = ? WHERE id = ?');
$stmt2->bindValue(1, "a");
$stmt2->bindValue(2, $row1['id']);
$stmt2->execute();
$stmt2->closeCursor();
$stmt1->execute();
$row4 = $stmt1->fetch(PDO::FETCH_ASSOC);
$stmt1->closeCursor();
assert($row4 == $row1);
$offset = 0;
$stmt = $db->prepare('SELECT id, label FROM test WHERE id > ? ORDER BY id ASC LIMIT 2');
$in = 0;
if (!$stmt->bindParam(1, $in)) {
printf("[%03d + 1] Cannot bind parameter, %s %s\n", $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true));
}
$stmt->execute();
$id = $label = null;
if (!$stmt->bindColumn(1, $id, PDO::PARAM_INT)) {
printf("[%03d + 2] Cannot bind integer column, %s %s\n", $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true));
}
if (!$stmt->bindColumn(2, $label, PDO::PARAM_STR)) {
printf("[%03d + 3] Cannot bind string column, %s %s\n", $offset, $stmt->errorCode(), var_export($stmt->errorInfo(), true));
}
while ($stmt->fetch(PDO::FETCH_BOUND)) {
printf("in = %d -> id = %s (%s) / label = %s (%s)\n", $in, var_export($id, true), gettype($id), var_export($label, true), gettype($label));
}
$stmt->closeCursor();
$stmt->execute();
}