Page MenuHomePhabricator
Authored By
stwalkerster
Jun 14 2017, 11:12 PM
Size
1 KB
Referenced Files
None
Subscribers
None
<?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');

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
20885
Default Alt Text
(1 KB)

Event Timeline