<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.keeganm.com/index.php?action=history&amp;feed=atom&amp;title=Mongo</id>
	<title>Mongo - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.keeganm.com/index.php?action=history&amp;feed=atom&amp;title=Mongo"/>
	<link rel="alternate" type="text/html" href="http://wiki.keeganm.com/index.php?title=Mongo&amp;action=history"/>
	<updated>2026-11-26T03:30:06Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>http://wiki.keeganm.com/index.php?title=Mongo&amp;diff=358&amp;oldid=prev</id>
		<title>Keegan at 13:28, 26 July 2013</title>
		<link rel="alternate" type="text/html" href="http://wiki.keeganm.com/index.php?title=Mongo&amp;diff=358&amp;oldid=prev"/>
		<updated>2013-07-26T13:28:34Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:28, 26 July 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=Backup=&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Dir Structure==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;mongodump -d games -o games.bak/&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=PHP=&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=PHP=&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Basic PHP Mongo OO Example==&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Basic PHP Mongo OO Example==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Keegan</name></author>
	</entry>
	<entry>
		<id>http://wiki.keeganm.com/index.php?title=Mongo&amp;diff=332&amp;oldid=prev</id>
		<title>Keegan: Created page with &quot;=PHP= ==Basic PHP Mongo OO Example== Used from http://techportal.inviqa.com/2010/11/30/using-mongodb-in-php-applications/  &lt;pre&gt; //index.php &lt;?php  	require_once(&quot;gameClass.php&quot;)...&quot;</title>
		<link rel="alternate" type="text/html" href="http://wiki.keeganm.com/index.php?title=Mongo&amp;diff=332&amp;oldid=prev"/>
		<updated>2013-02-18T18:35:13Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;=PHP= ==Basic PHP Mongo OO Example== Used from http://techportal.inviqa.com/2010/11/30/using-mongodb-in-php-applications/  &amp;lt;pre&amp;gt; //index.php &amp;lt;?php  	require_once(&amp;quot;gameClass.php&amp;quot;)...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=PHP=&lt;br /&gt;
==Basic PHP Mongo OO Example==&lt;br /&gt;
Used from http://techportal.inviqa.com/2010/11/30/using-mongodb-in-php-applications/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
//index.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
	require_once(&amp;quot;gameClass.php&amp;quot;);&lt;br /&gt;
	&lt;br /&gt;
	$m = new Mongo(&amp;quot;localhost&amp;quot;);&lt;br /&gt;
	$gamePeer = new GamePeer($m-&amp;gt;selectDb(&amp;quot;games&amp;quot;));&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
	$id = new MongoId(&amp;quot;511a6286d0eff4ff64000000&amp;quot;);&lt;br /&gt;
	foreach ($gamePeer-&amp;gt;fetchById($id) as $game)&lt;br /&gt;
	{&lt;br /&gt;
		print_r($game);&lt;br /&gt;
	}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
//gameClass.php&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
	class Game&lt;br /&gt;
	{&lt;br /&gt;
		private $gameId;&lt;br /&gt;
		private $gameTitle;&lt;br /&gt;
		&lt;br /&gt;
		//gameId is a mongoId type&lt;br /&gt;
		public function Game($opts = Array())&lt;br /&gt;
		{&lt;br /&gt;
			//existing game&lt;br /&gt;
			if(isset($opts[&amp;#039;gameId&amp;#039;]))&lt;br /&gt;
			{&lt;br /&gt;
				$this-&amp;gt;gameId = $opts[&amp;#039;gameId&amp;#039;];&lt;br /&gt;
			}&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public function getGameId()&lt;br /&gt;
		{&lt;br /&gt;
			return $this-&amp;gt;gameId;&lt;br /&gt;
		}&lt;br /&gt;
		public function setGameId($gameId)&lt;br /&gt;
		{&lt;br /&gt;
			$this-&amp;gt;gameId = $gameId;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public function getGameTitle()&lt;br /&gt;
		{&lt;br /&gt;
			return $this-&amp;gt;gameTitle;&lt;br /&gt;
		}&lt;br /&gt;
		public function setGameTitle($gameTitle)&lt;br /&gt;
		{&lt;br /&gt;
			$this-&amp;gt;gameTitle = $gameTitle;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	class GamePeer&lt;br /&gt;
	{&lt;br /&gt;
		const COLLECTION = &amp;#039;games&amp;#039;;&lt;br /&gt;
	   const ID_FIELD = &amp;#039;title&amp;#039;;&lt;br /&gt;
	   const DB_ID_FIELD = &amp;#039;_id&amp;#039;;&lt;br /&gt;
	 &lt;br /&gt;
	   private $db;&lt;br /&gt;
	   private $coll;&lt;br /&gt;
	 &lt;br /&gt;
	   public function __construct(MongoDb $db)&lt;br /&gt;
	   {&lt;br /&gt;
	   	$this-&amp;gt;db = $db;&lt;br /&gt;
	   }&lt;br /&gt;
	   &lt;br /&gt;
		private function getCollection()&lt;br /&gt;
		{&lt;br /&gt;
			// if the collection is not already cached&lt;br /&gt;
			if (empty($this-&amp;gt;collection)) &lt;br /&gt;
			{&lt;br /&gt;
				// selects the collection if it exists&lt;br /&gt;
				$this-&amp;gt;collection = $this-&amp;gt;db-&amp;gt;selectCollection(self::COLLECTION);&lt;br /&gt;
				 &lt;br /&gt;
				// or creates a new one if it doesn&amp;#039;t&lt;br /&gt;
				if (empty($this-&amp;gt;collection)) &lt;br /&gt;
				{&lt;br /&gt;
					$this-&amp;gt;collection = $this-&amp;gt;db-&amp;gt;createCollection(self::COLLECTION);&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		 &lt;br /&gt;
			return $this-&amp;gt;collection;&lt;br /&gt;
		}&lt;br /&gt;
		&lt;br /&gt;
		public function fetchAll()&lt;br /&gt;
	   {&lt;br /&gt;
	      // perform a find with a blank query&lt;br /&gt;
		   return $this-&amp;gt;getCollection()-&amp;gt;find();&lt;br /&gt;
	   }&lt;br /&gt;
	   &lt;br /&gt;
	   public function fetchById($id)&lt;br /&gt;
	   {&lt;br /&gt;
	   	$crit = Array(&amp;#039;_id&amp;#039; =&amp;gt; $id);&lt;br /&gt;
	   	&lt;br /&gt;
	   	$result = $this-&amp;gt;getCollection()-&amp;gt;findOne($crit);&lt;br /&gt;
	   	&lt;br /&gt;
	   	if($result)&lt;br /&gt;
	   	{&lt;br /&gt;
	   		return $result;&lt;br /&gt;
	   	}&lt;br /&gt;
	   }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Keegan</name></author>
	</entry>
</feed>