Rubellum fly light

ほぼPHP日記

phpDataMapper

phpDataMapper なるものを発見。
今まで ORM でよさげなものがなかったので超気になってる。
Ruby の DataMapper をなぞって作ってみるみたい。

Home | phpDataMapper – PHP DataMapper ORM
http://phpdatamapper.com/:image:large

ただ MySQL+UTF8 で案の定文字化け。
原因はやっぱり PDO 。
とりあえず接続を確立するときのコードを修正。

Adapter/PDO.php(46〜53行目)

// Establish connection
try {
  $this->connection = new PDO($this->dsn(), $this->username, $this->password, $this->options);

  // Throw exceptions by default
  $this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

  $this->connection->query('SET NAMES utf8');  # ← 追加!