我明白了
警告:spl_object_hash() 期望参数 1 是对象,布尔值在 /Path/vendor/doctrine-mongodb-odm/lib/Doctrine/ODM/MongoDB/UnitOfWork.php 第 1504 行中给出
当我尝试执行 $dm->flush(); 时出错 我坚持这样的对象
$eve = new Event();
$eve->setEvent($event);
这$event
是使用 setEvent() 函数转换为对象的数组。
事件类如下所示。
<?php
namespace CE\MainBundle\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
/**
* @MongoDB\Document(collection="events")
* @MongoDB\Index(keys={"coordinates"="2d"})
*/
Class Event{
/**
* @MongoDB\Id
*/
protected $id;
/**
* @MongoDB\String
* @MongoDB\Index(unique=true,order="asc")
*/
protected $eid;
/**
* @MongoDB\Int
*/
protected $start_time;
/**
* @MongoDB\Int
*/
protected $end_time;
/**
* @MongoDB\String
*/
protected $title;
/**
* @MongoDB\String
*/
protected $description;
/**
* @MongoDB\String
*/
protected $host;
/**
* @MongoDB\String
*/
protected $location;
/**
* @MongoDB\String
*/
protected $pic_square;
/**
* @MongoDB\EmbedOne(targetDocument="Coordinates")
*/
protected $coordinates=array();
/**
* @MongoDB\Int
* @MongoDB\Index(order="asc")
*/
protected $city_id;
/**
* @MongoDB\String
*/
protected $city_name;
/**
* @MongoDB\String
*/
protected $country;
/**
* @MongoDB\String
*/
protected $timezone;
/**
* @MongoDB\String
*/
protected $owner;
/**
* @MongoDB\Collection
* @MongoDB\Index(order="asc")
*/
protected $tags = array();
/**
* @MongoDB\EmbedOne(targetDocument="Event_status")
*/
protected $event_status = array();
/**
* Get id
*
* @return id $id
*/
public function getId()
{
return $this->id;
}
/**
* Set eid
*
* @param string $eid
*/
public function setEid($eid)
{
$this->eid = $eid;
}
/**
* Get eid
*
* @return string $eid
*/
public function getEid()
{
return $this->eid;
}
/**
* Set start_time
*
* @param int $startTime
*/
public function setStartTime($startTime)
{
$this->start_time = $startTime;
}
/**
* Get start_time
*
* @return int $startTime
*/
public function getStartTime()
{
return $this->start_time;
}
/**
* Set end_time
*
* @param int $endTime
*/
public function setEndTime($endTime)
{
$this->end_time = $endTime;
}
/**
* Get end_time
*
* @return int $endTime
*/
public function getEndTime()
{
return $this->end_time;
}
/**
* Set title
*
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* Get title
*
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set description
*
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* Get description
*
* @return string $description
*/
public function getDescription()
{
return $this->description;
}
/**
* Set host
*
* @param string $host
*/
public function setHost($host)
{
$this->host = $host;
}
/**
* Get host
*
* @return string $host
*/
public function getHost()
{
return $this->host;
}
/**
* Set location
*
* @param string $location
*/
public function setLocation($location)
{
$this->location = $location;
}
/**
* Get location
*
* @return string $location
*/
public function getLocation()
{
return $this->location;
}
/**
* Set pic_square
*
* @param string $picSquare
*/
public function setPicSquare($picSquare)
{
$this->pic_square = $picSquare;
}
/**
* Get pic_square
*
* @return string $picSquare
*/
public function getPicSquare()
{
return $this->pic_square;
}
/**
* Set coordinates
*
* @param CE\MainBundle\Document\coordinates $coordinates
*/
public function setCoordinates(\CE\MainBundle\Document\Coordinates $coordinates)
{
$this->coordinates = $coordinates;
}
/**
* Get coordinates
*
* @return CE\MainBundle\Document\coordinates $coordinates
*/
public function getCoordinates()
{
return $this->coordinates;
}
/**
* Set city_id
*
* @param int $cityId
*/
public function setCityId($cityId)
{
$this->city_id = $cityId;
}
/**
* Get city_id
*
* @return int $cityId
*/
public function getCityId()
{
return $this->city_id;
}
/**
* Set city_name
*
* @param string $cityName
*/
public function setCityName($cityName)
{
$this->city_name = $cityName;
}
/**
* Get city_name
*
* @return string $cityName
*/
public function getCityName()
{
return $this->city_name;
}
/**
* Set country
*
* @param string $country
*/
public function setCountry($country)
{
$this->country = $country;
}
/**
* Get country
*
* @return string $country
*/
public function getCountry()
{
return $this->country;
}
/**
* Set timezone
*
* @param string $timezone
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
}
/**
* Get timezone
*
* @return string $timezone
*/
public function getTimezone()
{
return $this->timezone;
}
/**
* Set owner
*
* @param int $owner
*/
public function setOwner($owner)
{
$this->owner = $owner;
}
/**
* Get owner
*
* @return int $owner
*/
public function getOwner()
{
return $this->owner;
}
/**
* Set tags
*
* @param collection $tags
*/
public function setTags($tags)
{
$this->tags = $tags;
}
/**
* Get tags
*
* @return collection $tags
*/
public function getTags()
{
return $this->tags;
}
/**
* Set event_status
*
* @param CE\MainBundle\Document\event_status $eventStatus
*/
public function setEventStatus(\CE\MainBundle\Document\Event_status $eventStatus)
{
$this->event_status = $eventStatus;
}
/**
* Get event_status
*
* @return CE\MainBundle\Document\event_status $eventStatus
*/
public function getEventStatus()
{
return $this->event_status;
}
public function setEvent($event){
$this->eid = $event['eid'];
$this->start_time = $event['start_time'];
$this->end_time = $event['end_time'];
$this->description = $event['description'];
$this->host = $event['host'];
$this->location = $event['location'];
$this->pic_square = $event['pic_square'];
$this->city_id = (int)$event['city_id'];
$this->city_name = $event['city_name'];
$this->country = $event['country'];
$this->timezone = $event['timezone'];
$this->owner = $event['owner'];
$this->title = $event['title'];
$this->tags = $event['tags'];
$loc=new Coordinates();
$loc->setLongitude($event['coordinates']['longitude']);
$loc->setLatitude($event['coordinates']['latitude']);
$this->coordinates = $loc;
$stat = new Event_status();
$stat->setAttendCount($event['event_status']['attend_count']);
$stat->setAttendList($event['event_status']['attend_list']);
$stat->setClickCount($event['event_status']['click_count']);
$this->event_status = $stat;
}
}
/**
* @MongoDB\EmbeddedDocument
*/
Class Coordinates{
/**
* @MongoDB\Float
*/
protected $longitude;
/**
* @MongoDB\Float
*/
protected $latitude;
/**
* Set longitude
*
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* Get longitude
*
* @return float $longitude
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Set latitude
*
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* Get latitude
*
* @return float $latitude
*/
public function getLatitude()
{
return $this->latitude;
}
}
/**
* @MongoDB\EmbeddedDocument
*/
Class Event_status{
/**
* @MongoDB\Int
*/
protected $attend_count;
/**
* @MongoDB\Int
* @MongoDB\Index(order="desc")
*/
protected $click_count;
/**
* @MongoDB\Collection
*/
protected $attend_list = array();
/**
* Set attend_count
*
* @param int $attendCount
*/
public function setAttendCount($attendCount)
{
$this->attend_count = $attendCount;
}
/**
* Get attend_count
*
* @return int $attendCount
*/
public function getAttendCount()
{
return $this->attend_count;
}
/**
* Set click_count
*
* @param int $clickCount
*/
public function setClickCount($clickCount)
{
$this->click_count = $clickCount;
}
/**
* Get click_count
*
* @return int $clickCount
*/
public function getClickCount()
{
return $this->click_count;
}
public function incClickCount($i){
$this->click_count = $this->click_count + $i;
}
/**
* Set attend_list
*
* @param collection $attendList
*/
public function setAttendList($attendList)
{
$this->attend_list = $attendList;
}
/**
* Get attend_list
*
* @return collection $attendList
*/
public function getAttendList()
{
return $this->attend_list;
}
}
我正在尝试坚持以下对象
object(CE\MainBundle\Document\Event)#302 (17) {
["id":protected]=>
NULL
["eid":protected]=>
string(15) "116189838391483"
["start_time":protected]=>
int(1356069600)
["end_time":protected]=>
int(1356080400)
["title":protected]=>
string(38) "Sex on December 20, 2012 Just In Case"
["description":protected]=>
string(322) "Spread the word
Maps : http://maps.google.nl/maps?f=q&source=s_q&hl=nl&q=Vondelpark,+1071+AA+Oud-Zuid,+Amsterd%C3%A3,+Amsterdam,+Noord-Holland&sll=52.469397,5.509644&sspn=5.134105,16.907959&ie=UTF8&geocode=FR_rHgMdG0pKAA&split=0&hq=&hnear=1071+AA+Amsterdam,+Noord-Holland&ll=52.360231,4.873273&spn=0.010051,0.033023&z=16
"
["host":protected]=>
string(19) "Sébastien Carvalho"
["location":protected]=>
string(21) "Amsterdam, VondelPark"
["pic_square":protected]=>
string(89) "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/71137_116189838391483_7509117_q.jpg"
["coordinates":protected]=>
object(CE\MainBundle\Document\Coordinates)#344 (2) {
["longitude":protected]=>
float(4.88969)
["latitude":protected]=>
float(52.37403)
}
["city_id":protected]=>
int(2759794)
["city_name":protected]=>
string(9) "Amsterdam"
["country":protected]=>
string(11) "Netherlands"
["timezone":protected]=>
string(16) "Europe/Amsterdam"
["owner":protected]=>
string(10) "1345873725"
["tags":protected]=>
array(39) {
[0]=>
string(3) "sex"
[1]=>
string(6) "decemb"
[2]=>
string(4) "just"
[3]=>
string(4) "case"
[4]=>
string(6) "spread"
[5]=>
string(4) "word"
[6]=>
string(3) "map"
[7]=>
string(1) ":"
[8]=>
string(5) "http:"
[9]=>
string(5) "googl"
[10]=>
string(2) "nl"
[11]=>
string(1) "f"
[12]=>
string(1) "q"
[13]=>
string(5) "sourc"
[14]=>
string(0) ""
[15]=>
string(2) "hl"
[16]=>
string(10) "vondelpark"
[17]=>
string(2) "aa"
[18]=>
string(3) "oud"
[19]=>
string(4) "zuid"
[20]=>
string(7) "amsterd"
[21]=>
string(2) "c3"
[22]=>
string(2) "a3"
[23]=>
string(9) "amsterdam"
[24]=>
string(5) "noord"
[25]=>
string(7) "holland"
[26]=>
string(3) "sll"
[27]=>
string(4) "sspn"
[28]=>
string(2) "ie"
[29]=>
string(4) "utf8"
[30]=>
string(6) "geocod"
[31]=>
string(2) "fr"
[32]=>
string(11) "rhgmdg0pkaa"
[33]=>
string(5) "split"
[34]=>
string(2) "hq"
[35]=>
string(5) "hnear"
[36]=>
string(2) "ll"
[37]=>
string(3) "spn"
[38]=>
string(1) "z"
}
["event_status":protected]=>
object(CE\MainBundle\Document\Event_status)#305 (3) {
["attend_count":protected]=>
int(0)
["click_count":protected]=>
int(0)
["attend_list":protected]=>
array(0) {
}
}
}
请告诉我错误在哪里?