Page MenuHomePhabricator
Paste P142

(An Untitled Masterwork)
ActivePublic

Authored by stwalkerster on Jun 14 2017, 11:12 PM.
<?php
include 'includes/PdoDatabase.php';
$db = new \Waca\PdoDatabase('mysql:host=localhost;dbname=stwalkerster_scratch', 'stwalkerster', '123', array(
// PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
));
$db2 = new \Waca\PdoDatabase('mysql:host=localhost;dbname=stwalkerster_scratch', 'stwalkerster', '123', array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4',
));
$name = '小綿羊寶貝';
$db->exec('TRUNCATE TABLE stwalkerster_scratch.request');
$db->exec('TRUNCATE TABLE stwalkerster_scratch.request2');
$db->prepare("INSERT INTO stwalkerster_scratch.request VALUES (:name);")->execute([':name' => $name]);
$db->prepare("INSERT INTO stwalkerster_scratch.request2 VALUES (:name);")->execute([':name' => $name]);
$statement = $db->prepare("SELECT name FROM stwalkerster_scratch.request;");
$statement->execute();
$utf = $statement->fetchColumn();
$statement = $db->prepare("SELECT name FROM stwalkerster_scratch.request2;");
$statement->execute();
$utfmb = $statement->fetchColumn();
var_dump($name);
var_dump(bin2hex($name));
var_dump($utf);
var_dump(bin2hex($utf));
var_dump($utfmb);
var_dump(bin2hex($utfmb));
$db2->exec('INSERT INTO acc_notifications.notification SELECT null, null, 2, name FROM stwalkerster_scratch.request');
$db2->exec('INSERT INTO acc_notifications.notification SELECT null, null, 2, name FROM stwalkerster_scratch.request2');

Event Timeline

stwalkerster created this object with visibility "Public (No Login Required)".