如何在MAMP中访问PDO?

I'm setting up a PDO connection in a test script:

use app\SomeDAO;

class SomeTest extends \PHPUnit_Framework_TestCase
{
    protected $db;

    public function setUp()
    {
        $dsn = "mysql:host=localhost;dbname=baseball;user=root;password=root";
        $this->db = new PDO($dsn);
    }

I'm getting an error:

PDOException: SQLSTATE[HY000] [2002] No such file or directory.

How can I use PDO here?

查看全部
duanlaiquan8174
duanlaiquan8174
2014/08/05 20:44
  • php
  • pdo
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复