예제 #1
0
 /**
  * Converts a single mongo document into the appropriate Morph_Object
  *
  * @param array $item
  * @return Morph_Object
  */
 private function createObject(array $item)
 {
     $class = \get_class($this->type);
     $object = new $class();
     $object->__setData($item, Enum::STATE_CLEAN)->collection($this->type->collection());
     return $object;
 }
예제 #2
0
파일: Utils.php 프로젝트: kulobone/mongodb
 /**
  * Generates an object reference for Has* properties
  *
  * @param $object
  * @return array
  */
 public static function objectReference(Morph_Object $object)
 {
     $reference = array('$ref' => $object->collection(), '$id' => $object->id());
     //causes a fatal error in PHP at present. Will try again later
     //$reference = MorphDBRef::create($object->collection(), $object->id());
     return $reference;
 }
예제 #3
0
 /**
  * (non-PHPdoc)
  * @see tao/classes/Morph/property/Morph_Property_Generic#__toString()
  */
 public function __toString()
 {
     $id = '';
     if(isset($this->value)){
         $id = $this->value->id();
     }elseif(isset($this->reference)){
         $id = $this->reference['$id'];
     }
     return $this->getName() . ": {" . $this->type . ": $id}";
 }
예제 #4
0
	public function __construct($id = null) {
	    parent::__construct($id);

	    $this->addProperty(new Morph_Property_String('userName'))
	         ->addProperty(new Morph_Property_String('firstName'))
	         ->addProperty(new Morph_Property_String('lastName'))
	         ->addProperty(new Morph_Property_Date('dateOfBirth'))
	         ->addProperty(new Morph_Property_Integer('numberOfPosts', 0));

	}
예제 #5
0
 public function __construct($id = null)
 {
     parent::__construct($id);
     $this->addProperty(new Morph_Property_Generic('TestField'));
 }
예제 #6
0
 /**
  * Deletes the object passed in from the database
  * @param Morph_Object $object
  * @return boolean
  */
 public function delete(Morph_Object $object)
 {
     $query = array('_id' => $object->id());
     return $this->Db->selectCollection($object->collection())->remove($query, true);
 }
예제 #7
0
파일: testOne.php 프로젝트: amitamb/Red
 public function __construct($id = null)
 {
     parent::__construct($id);
     $this->addProperty(new Morph_Property_String('title'))->addProperty(new Morph_Property_String('author'))->addProperty(new Morph_Property_Integer('pageNumber'))->addProperty(new Morph_Property_Date('publishedDate'));
 }