Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/296.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Utf8、瑞典语字符、条令、Mysql和Json序列化_Php_Mysql_Json_Utf 8_Doctrine Orm - Fatal编程技术网

Php Utf8、瑞典语字符、条令、Mysql和Json序列化

Php Utf8、瑞典语字符、条令、Mysql和Json序列化,php,mysql,json,utf-8,doctrine-orm,Php,Mysql,Json,Utf 8,Doctrine Orm,我有一个应用程序,我正在试用Doctrine2。我有一个配置了InnoDB类型和排序规则utf8\uUnicode\uCI的数据库,然后有一个简单的表,它有两列:id(整数)和name(字符串) 我使用phpmyadmin在表中输入一行,然后使用以下代码从数据库中读取信息: $serializer = JMS\Serializer\SerializerBuilder::create()->build(); $county = $entityManager->find('County'

我有一个应用程序,我正在试用Doctrine2。我有一个配置了InnoDB类型和排序规则utf8\uUnicode\uCI的数据库,然后有一个简单的表,它有两列:id(整数)和name(字符串)

我使用phpmyadmin在表中输入一行,然后使用以下代码从数据库中读取信息:

$serializer = JMS\Serializer\SerializerBuilder::create()->build();
$county = $entityManager->find('County', 1);
$jsonContent = $serializer->serialize($county, 'json');
我使用的序列化程序来自

我的县实体文件如下所示:

    <?php
use Doctrine\ORM\Mapping as ORM;

// src/County.php
/** @ORM\Entity **/
class County
{
    /** @ORM\Id @ORM\Column(type="integer") **/
    protected $id;

    /** @ORM\Column(type="string") * */
    protected $name;


    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }
}

我想出来了。我向连接对象添加了字符集,然后它就可以工作了

$conn = array(
'driver' => 'pdo_mysql',
'dbname' => 'doctrine',
'user' => 'doctrine',
'password' => 'doctrine',
'host' => 'localhost',
'charset' => 'UTF8'
);

我想出来了。我向连接对象添加了字符集,然后它就可以工作了

$conn = array(
'driver' => 'pdo_mysql',
'dbname' => 'doctrine',
'user' => 'doctrine',
'password' => 'doctrine',
'host' => 'localhost',
'charset' => 'UTF8'
);