Permalink
Browse files

merged...again

  • Loading branch information...
2 parents 491fe27 + 5c36d63 commit 940eed80fa0aaeb0104a88f7a331017e07fa8748 @mgrandi committed Jun 2, 2011
Showing with 13 additions and 69 deletions.
  1. +7 −23 src/morph/Object.php
  2. +6 −46 src/morph/Storage.php
View
@@ -210,6 +210,9 @@ public function save(array $options = array())
* Attempts to load the current object with data from the document id specified
* this is meant for if the _id is not necessarily an ObjectId
*
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
+ *
* @param mixed $id
* @return Morph_Object
*/
@@ -219,18 +222,10 @@ public function loadById($id)
}
/**
- * Attempts to load the current object with data from the document id specified
- *
- * @param mixed $id
- * @return Morph_Object
- */
- public function loadByObjectId($id)
- {
- return Storage::instance()->fetchByObjectId($this, $id);
- }
-
- /**
* Fetch multiple objects by their ids
+ *
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param array $ids
* @return Morph_Iterator
@@ -239,18 +234,7 @@ public function findByIds(array $ids)
{
return Storage::instance()->fetchByIds($this, $ids);
}
-
- /**
- * Fetch multiple objects by their ids
- *
- * @param array $ids
- * @return Morph_Iterator
- */
- public function findByObjectIds(array $ids)
- {
- return Storage::instance()->fetchByObjectIds($this, $ids);
- }
-
+
/**
* Find objects by query
*
View
@@ -94,10 +94,9 @@ public function getDatabase()
/**
* Retrieves the contents of the specified $id
* and assigns them into $object
- *
- * This shoudld be used if the _id is not necessarily a ObjectId()
- * (or the php version, MongoId() ). You can always just wrap the id string
- * in new \MongoId() as well
+ *
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param Morph\\Object $object
* @param mixed $id
@@ -109,28 +108,12 @@ public function fetchById(Object $object, $id)
$data = $this->db->selectCollection($object->collection())->findOne($query);
return $this->setData($object, $data);
}
-
- /**
- * Retrieves the contents of the specified $id
- * and assigns them into $object
- * This function is meant for if the _id is a ObjectId (the default)
- *
- * @param Morph\\Object $object
- * @param mixed $id
- * @return Morph\\Object
- */
- public function fetchByObjectId(Object $object, $id)
- {
- if (is_string($id)) {
- $id = new \MongoId($id);
- }
- $query = array('_id' => $id);
- $data = $this->db->selectCollection($object->collection())->findOne($query);
- return $this->setData($object, $data);
- }
/**
* Returns all objects with an _id in $ids
+ *
+ * By default Morph sets the id to be an instance of MongoId(). When searching you need
+ * to ensure you do the same by wrapping your id string in a MongoId object
*
* @param Morph\\Object $object
* @param array $Ids
@@ -142,29 +125,6 @@ public function fetchByIds(Object $object, array $ids)
$query->property('_id')->in($ids);
return $this->findByQuery($object, $query);
}
-
- /**
- * Returns all objects with an _id in $ids
- *
- * @param Morph\\Object $object
- * @param array $Ids
- * @return Morph\\Iterator
- */
- public function fetchObjectByIds(Object $object, array $ids)
- {
- $query = new Query();
- $wrappedIds = array();
- foreach ($ids as $id) {
- if (is_string($id)) {
- $wrappedIds[] = new \MongoId($id);
- } else {
- $wrappedIds[] = $id;
- }
- }
-
- $query->property('_id')->in($ids);
- return $this->findByQuery($object, $query);
- }
/**
* Retrieves the contents of the specified $dbRef

0 comments on commit 940eed8

Please sign in to comment.