public function __construct($value = null) { if (!$value instanceof \MongoId) { $value = new \MongoId($value); } $this->value = $value->__toString(); }
public static function setMongoIdForClasses($objectRef) { $mongoId = new MongoId(); $objectRef->_id = $mongoId; $objectRef->id = $mongoId->__toString(); return $objectRef; }
function it_transforms_product_fields_result(\MongoId $id) { $locale = 'fr_FR'; $id->__toString()->willReturn(42); $result = ['_id' => $id, 'created' => null, 'updated' => null, 'enabled' => null]; $expected = ['created' => null, 'updated' => null, 'enabled' => false, 'id' => 42, 'dataLocale' => 'fr_FR']; $this->transform($result, $locale)->shouldReturn($expected); }
<?php $id = new MongoId(); if (getmypid() <= 65536) { $retval = $id->getPid() == getmypid(); } else { $retval = true; } var_dump($id->getPid(), $id->__toString(), $retval); $id = new MongoID("4fe3420a44415ecc83000000"); var_dump($id->getPid(), $id->__toString()); $id = new MongoID("4fe3427744415e4f84000001"); var_dump($id->getPid(), $id->__toString()); $id = new MongoID("4fe342a944415e5284000000"); var_dump($id->getPid(), $id->__toString());
/** * getPlainObject * @return \MongoId */ public function getPlainObject() { return new \MongoId(parent::__toString()); }
<?php $x = new MongoId(NULL); $x->__construct(NULL); $x->getInc(NULL); var_dump($x->__toString()); ?> ===DONE===
public function getLastInsertId() { return $this->lastInsertId ? $this->lastInsertId->__toString() : null; }
<?php MongoId::getHostname(); MongoId::__toString(); MongoId::getTimestamp(); MongoId::isValid(); MongoId::__set_state(); MongoId::getInc(); MongoId::getPID(); $collection->save(array("ts" => new MongoDate())); $start = new MongoDate(strtotime("2010-01-15 00:00:00")); $end = new MongoDate(strtotime("2010-01-30 00:00:00")); $collection->find(array("ts" => array('$gt' => $start, '$lte' => $end))); $search = "V"; $where = array('name' => array(' $regex' => new MongoRegex("/^{$search}/"))); $cursor = $collection->find($where); $where = array('name' => array('$regex' => new MongoRegex("/^{$search}/i"))); $profile = array("username" => 'foobity', "pic" => new MongoBinData(file_get_contents("gravatar.jpg"), MongoBinData::GENERIC)); $connection->save($profile); $people = $db->people; $addresses = $db->addresses; $myAddress = array("line 1" => '12 main sreet', 'line 2' => null, 'city' => 'beijing', 'state' => "vermont", 'country' => 'china'); $addresses->insert($myAddress); $me = array('name' => 'fred', 'address' => $myAddress['_id']); $people->insert($me);
public function testMongoIdMongoId() { $id = new \MongoId(); $funkId = new \MongoFunk\MongoId($id); $this->assertSame($id->__toString(), $funkId->__toString(), "Mongo Id should return the passed id"); }
public function setId($object, \MongoId $id) { $object->id = $id->__toString(); }
function getNewId() { $newId = new \MongoId(); return $newId->__toString(); }
private function convertRowValues($row) { $id = new MongoId($row["_id"]); $time_stamp = $row["lastModified"]->sec; //$id->getTimestamp(); $dt = new DateTime("@{$time_stamp}"); $row["created"] = $dt->format('F d, Y g:i'); $row["id"] = $id->__toString(); //parse date modified to use in direct URL to post $date_of_post = date_parse($row["created"]); $row["month"] = $date_of_post["month"]; $row["day"] = $date_of_post["day"]; $row["year"] = $date_of_post["year"]; $row["safe_title"] = $this->convertPostTitleSpacesToHyphens($row["title"]); return $row; }
$res = $col->messageGroups->update(array("messageData.conversationId" => $item["message"]["object"]["conversationId"]), array('$set' => array("lastAction" => new MongoDate(), "sendername" => $item["sendername"], "preview" => $item["message"]["object"]["preview"])), array("multiple" => true)); } } break; case "message_distribute": $col = \App\DB\Get::Collection(); $cursor2 = $col->users->findOne(array("userid" => $_SESSION["charme_userid"]), array("firstname", "lastname")); $sendername = $cursor2["firstname"] . " " . $cursor2["lastname"]; $messageData = $item["messageData"]["obj"]; $conversationId = $item["messageData"]["conversationId"]; $messageData["sendername"] = $sendername; if ($messageData["action"] == "initConversation" || $messageData["action"] == "addPeople") { // Create a unique Id for each conversation if (!isset($item["messageData"]["conversationId"])) { $mid = new MongoId(); $item["messageData"]["conversationId"] = $mid->__toString(); $conversationId = $mid->__toString(); } // for ($i = 0; $i<Count($messageData["usernames"]); $i++) // { // if ($messageData["usernames"][$i]["userId"] == $_SESSION["charme_userid"]) // $messageData["usernames"][$i]["name"] = $sendername; // } foreach ($messageData["usernames"] as $userTuple) { $receiverId = $userTuple["userId"]; $keyobj = array(); // Get the message key foreach ($item["messageKeys"] as $value) { if ($value["userId"] == $receiverId) { $keyobj = $value; }