<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -10,7 +10,8 @@ class DZApi extends Controller {
 	
 	function index()
 	{
-		$this-&gt;load-&gt;view('welcome_message');
+		// $this-&gt;load-&gt;view('welcome_message');
+		
 	}
 	
 	
@@ -44,14 +45,56 @@ class DZApi extends Controller {
 	/**
 	 * Gets data for a single entry
 	 *
-	 * @param integet $id 
+	 * @param integer $id 
 	 * @return void
 	 * @author Ed Finkler
 	 */
 	public function single($id)
 	{
-		echo &quot;hi! you requested $id&quot;;
-		# code...
+		$id  = (int)$id;
+		
+		$row = $this-&gt;mletters-&gt;getOne($id);
+
+		if ($row !== false) {
+
+			$data['row'] = $row;
+			$response-&gt;letter = $row;
+			$response-&gt;msg    = 'Retrieved post '.$id;
+			$response-&gt;count  = count($result);
+			$this-&gt;_sendAsJSON($response, '200 OK');
+
+		} else {
+			$response-&gt;msg = 'I couldn\'t find a random post';
+			$this-&gt;_sendAsJSON($response, '500 Internal Server Error');
+		}
+		return;
+	}
+	
+	
+	/**
+	 * Gets data for a single entry
+	 *
+	 * @param integet $id 
+	 * @return void
+	 * @author Ed Finkler
+	 */
+	public function random()
+	{
+		$row = $this-&gt;mletters-&gt;getRandom();
+
+		if ($row !== false) {
+
+			$data['row'] = $row;
+			$response-&gt;letter = $row;
+			$response-&gt;msg    = 'Retrieved random post';
+			$response-&gt;count  = count($result);
+			$this-&gt;_sendAsJSON($response, '200 OK');
+
+		} else {
+			$response-&gt;msg = 'I couldn\'t find post '.$id;
+			$this-&gt;_sendAsJSON($response, '500 Internal Server Error');
+		}
+		return;
 	}
 	
 	</diff>
      <filename>system/application/controllers/dzapi.php</filename>
    </modified>
    <modified>
      <diff>@@ -106,8 +106,8 @@ class Site extends Controller {
 
 
 		} else {
-			$response-&gt;msg = 'There was a problem adding your post';
-			$this-&gt;_sendAsJSON($response, '500 Internal Server Error');
+			$this-&gt;session-&gt;set_flashdata('flash_msg', 'I couldn\t find that post');
+			redirect('/site/index');
 		}
 		return;
 	}</diff>
      <filename>system/application/controllers/site.php</filename>
    </modified>
    <modified>
      <diff>@@ -29,6 +29,7 @@ class MLetters extends Model {
 	}
 	
 	
+	
 	/**
 	 * retrieve an array of entries
 	 *
@@ -102,7 +103,7 @@ class MLetters extends Model {
 	
 
 	/**
-	 * retrieve an array of entries
+	 * retrieve an array of entries. This could get ugly if the count gets big
 	 *
 	 * @param int $count default 10
 	 * @param string $sortby a column name
@@ -131,6 +132,20 @@ class MLetters extends Model {
 	}
 
 
+	/**
+	 * returns a random entry. This is wildly inefficient
+	 *
+	 * @return stdObj
+	 * @author Ed Finkler
+	 */
+	public function getRandom()
+	{
+		$results = $this-&gt;getAll();
+		$randkey = array_rand($results);
+		return $results[$randkey];
+	}
+
+
 	
 	/**
 	 * add a new entry</diff>
      <filename>system/application/models/mletters.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ece5411e9384bddafa7680a5111d08b5624f0229</id>
    </parent>
  </parents>
  <author>
    <name>Ed Finkler</name>
    <email>coj@SniperWolf.local</email>
  </author>
  <url>http://github.com/funkatron/dearzend-server/commit/6975740113ed87c115692b44149d71e1f779af16</url>
  <id>6975740113ed87c115692b44149d71e1f779af16</id>
  <committed-date>2008-09-17T09:16:51-07:00</committed-date>
  <authored-date>2008-09-17T09:16:51-07:00</authored-date>
  <message>- added a random function to the API
- cleaned up some error message stuff</message>
  <tree>bd4c4f16a255c60c9a0f7fd5a66be1890d530654</tree>
  <committer>
    <name>Ed Finkler</name>
    <email>coj@SniperWolf.local</email>
  </committer>
</commit>
