我正在将Doctrine2整合到CodeIgniter中。如何将Doctrine数组转换为PHP关联数组
我的实体类News.php
<?php
namespace Models\Entities;
/**
* News
*
* @Table(name="news", indexes={@Index(name="slug", columns={"slug"})})
* @Entity
*/
class News {
//HERE: properties, getter, setter, etc.
}
我的模型类News_model.php
<?php
require_once(APPPATH."models/entities/News.php");
use Models\Entities\News;
class News_model extends CI_Model {
//Model code here
}
当我使用$消息= $这个 - > EM-> getRepository('实体:新闻“) - >的findAll()在News_model类和印刷,后续代码var_dump($消息),我得到的对象(模型数组\实体\新闻),就像如下:
array (size=6)
0 =>
object(Models\Entities\News)[87]
private 'id' => int 1
private 'title' => string 'text here' (length=9)
private 'slug' => string '' (length=0)
private 'text' => string 'text here' (length=9)
private 'news' => null
)
但我预计的关联数组,就像如下:
array (size=6)
0 =>
array (size=4)
'id' => string '1' (length=1)
'title' => string 'text here' (length=9)
'slug' => string '' (length=0)
'text' => string 'text here' (length=9)
)
我怎么能转换主义实体对象(第一显示阵列)导致的PHP关联数组(第二显示阵列)?
谢谢,我适应与对象的工作的看法。 – omixam