<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -471,26 +471,31 @@ function get_instance(){
 
 
 /**
- * Creates pagination links for the number of pages given
- *
- * @param array $options
- * @return array
+ * Creates pagination links for the total number of pages
+ * @param	array	$options
+ * @param	bool	$load_view
+ * @return	mixed
  */
-function pagination($options=null) {
+function pagination($options=null, $load_view = FALSE) {
 
 	/** [Options]
 	 * total		Total number of items
 	 * per_page		Items to show each page
-	 * current_page	The current page that the user is on
+	 * current		The current page that the user is on
+	 * num_links	The number of links to show before and after the current page
 	 * url			URI value to place in the links (must include &quot;[[page]]&quot;)
 	 * 				Example: /home/blog/page/[[page]]/
 	 */
 
-	//Don't allow page 0 or lower
-	if($options['current_page'] &lt; 0) {
-		$options['current_page'] = 0;
+	//Max links to show
+	if(empty($options['num_links'])) {
+		$options['num_links'] = 2;
 	}
 
+	//Don't allow page 0 or lower
+	if($options['current'] &lt; 1) {
+		$options['current'] = 1;
+	}
 
 	//Initialize
 	$data = array(
@@ -502,30 +507,51 @@ function pagination($options=null) {
 	);
 
 	//The offset to start from. This is useful if you are running a DB query
-	if($options['current_page'] &gt; 1) {
-		$data[&quot;offset&quot;] = (($options['per_page'] * $options['current_page']) - $options['per_page']);
-	}
+	//$data[&quot;offset&quot;] = (($options['per_page'] * $options['current']) - $options['per_page']);
 
 	//The Number of pages based on the total number of items and the number to show each page
 	$data['total'] = ceil($options['total'] / $options['per_page']);
 
-	//If there is more than one page...
-	if($data['total'] &gt; 1) {
+	//Current page should NOT be past last page
+	if($options['current'] &gt; $data['total']) {
+		$options['current'] = $data['total'];
+	}
 
-		//If this is NOT the first page - show a previous link
-		if($options['current_page'] &gt; 1) {
-			$data['previous'] = str_replace('[[page]]', ($options['current_page'] - 1), $options['url']);
-		}
+	//If there is only one (or less) pages
+	if($data['total'] &lt;= 1) {
+		return;
+	}
 
-		//If this isn't the last page - add a &quot;next&quot; link
-		if($options['current_page'] + 1 &lt; $data['total']) {
-			$data[&quot;next&quot;] = str_replace('[[page]]', ($options['current_page'] + 1), $options['url']);
-		}
+	//If this is NOT the first page - show a previous link
+	if($options['current'] &gt; 1) {
+		$data['previous'] = str_replace('[[page]]', ($options['current'] - 1), $options['url']);
 	}
 
+	//If this isn't the last page - add a &quot;next&quot; link
+	if($options['current'] + 1 &lt; $data['total']) {
+		$data[&quot;next&quot;] = str_replace('[[page]]', ($options['current'] + 1), $options['url']);
+	}
+
+	//Show first page?
+	if($options['current'] &gt; $options['num_links'] + 1) {
+		$data['first'] = str_replace('[[page]]', 1, $options['url']);
+	}
+
+	//Show last page?
+	if($options['current'] + $options['num_links'] &lt; $data['total']) {
+		$data['last'] = str_replace('[[page]]', $data['total'], $options['url']);
+	}
+
+
+	//Only if we have more pages than links to show
+	$start = (($options['current'] - $options['num_links']) &gt; 0) ? $options['current'] - ($options['num_links']) : 1;
+	$end   = (($options['current'] + $options['num_links']) &lt; $data['total']) ? $options['current'] + $options['num_links'] : $data['total'];
+
+	//print 'Total Rows: '. $options['total']. ' Pages: '. $data['total']. ' End: '. $end. ' Start: '. $start;
+
 	//For each page, create the URL
-	for($i = 0; $i &lt; $data['total']; $i++) {
-		if($options['current_page'] == $i) {
+	for($i = $start; $i &lt;= $end; $i++) {
+		if($options['current'] == $i) {
 			$data['links'][$i] = '';
 		} else {
 			//Replace [[page]] with the page number
@@ -533,7 +559,16 @@ function pagination($options=null) {
 		}
 	}
 
-	return $data;
+	//If we should just return the array
+	if( ! $load_view) {
+		return $data;
+	}
+
+	//Fetch the Controller instance
+	$mvc = get_instance();
+
+	//Place it in the view
+	return $mvc-&gt;view('pagination', $data, TRUE);
 }
 
 </diff>
      <filename>functions/common.php</filename>
    </modified>
    <modified>
      <diff>@@ -886,6 +886,7 @@ class db {
 	 * @param	string
 	 */
 	public function select($select = '*', $escape = NULL){
+
 		$qi = $this-&gt;quote_identifier();
 
 		//If string - convert to an array
@@ -895,18 +896,31 @@ class db {
 
 		$string = '';
 		foreach($select as $value) {
+
+			//If there is no column...
+			if( ! $value = trim($value)) {	continue; }
+
 			//If this is a string without quotes, without a function like COUNT() or MAX()), or without a star
 			if(strpos($value, $qi) === FALSE &amp;&amp; strpos($value, '(') === FALSE &amp;&amp; strpos($value, '*') === FALSE) {
+
+				//If they are using table.field values...
+				if(strpos($value, '.') !== FALSE) {
+					$value = explode('.', $value);
+					$value = implode($qi. '.'. $qi, $value);
+				}
+
 				//Then quote the value
 				$string .= $qi. trim($value). $qi. ',';
 			} else {
 				$string .= trim($value). ',';
 			}
+
 		}
 
 		//Register the select and remove last comma
 		$this-&gt;orm_select = rtrim($string, ',');
 
+		//print_pre($select, $string);
 		return $this;
 	}
 
@@ -1179,6 +1193,62 @@ class db {
 	}
 
 
+	/**
+	 * Fetch infomation about the fields in a given table. Performs a
+	 * SELECT of one row in order to find column data.
+	 *
+	 * @param	string	$table
+	 * @return	array
+	 */
+	public function field_data($table = NULL) {
+
+		//Select any example row
+		$sql = 'SELECT * FROM '. $this-&gt;quote_table($table). ' LIMIT 1';
+
+		//If we are loggin queries
+		if($this-&gt;log_queries) {
+			$this-&gt;queries[] = $sql;
+		}
+
+		$result = $this-&gt;pdo-&gt;query($sql);
+
+		//PDO data types
+		$types = array(
+			PDO::PARAM_BOOL =&gt; 'bool',
+			PDO::PARAM_NULL	=&gt; 'null',
+			PDO::PARAM_INT	=&gt; 'int',
+			PDO::PARAM_STR	=&gt; 'string',
+			PDO::PARAM_LOB	=&gt; 'blob',
+			PDO::PARAM_STMT	=&gt; 'statement'	//Not used right now
+		);
+
+		$columns = array();
+
+		if($result &amp;&amp; $number = $result-&gt;columnCount()) {
+			for($x=0;$x&lt;$number;$x++) {
+
+				//Get meta
+				$column = $result-&gt;getColumnMeta($x);
+
+				//If the column lenght isn't set - default to ZERO
+				$column['len'] = isset($column['len']) ? $column['len'] : 0;
+
+				//HACK: If it is longer than 255 chars then it is a text area
+				if($column['len'] &gt; 255) {
+					$column['type'] = 'text';
+				} else {
+					$column['type'] = $types[$column['pdo_type']];
+				}
+
+				//Save type information
+				$columns[$column['name']] = $column;
+			}
+		}
+
+		return $columns;
+	}
+
+
 	/*
 	 ------------------------------------------
 	 Alias Functions
@@ -1233,7 +1303,7 @@ class db {
 
 	/*
 	 * Access PDO methods as it we were the PDO object
-	 */
+	 *
 	public function __call($name, $arguments) {
 		//return call_user_func(array($this-&gt;pdo, $name), $arguments);
 		return $this-&gt;pdo-&gt;$name($arguments);
@@ -1242,7 +1312,7 @@ class db {
 
 	/*
 	 * Access PDO properties as if we were the PDO object
-	 */
+	 *
 	public function __get($name) {
 		return $this-&gt;pdo-&gt;$name;
 	}
@@ -1326,6 +1396,7 @@ class mysql extends db {
 		return $tables;
 	}
 
+
 	/**
 	 * Explain all columns within a table
 	 */</diff>
      <filename>libraries/db.php</filename>
    </modified>
    <modified>
      <diff>@@ -23,10 +23,10 @@ class session {
 	public $session_name		= 'mvc_session';	//What should the session be called?
 	public $session_id			= NULL;				//Specify a custom ID to use instead of default cookie ID
 
-	public $cookie_path			= NULL;				//Path to set in session_cookie
+	public $cookie_path			= '/';				//Path to set in session_cookie
 	public $cookie_domain		= NULL;				//The domain to set in session_cookie
 	public $cookie_secure		= NULL;				//Should cookies only be sent over secure connections?
-	public $cookie_httponly		= NULL;				//Only accessible through the HTTP protocol?
+	public $cookie_httponly		= NULL;				//Only accessible through the HTTP protocol? PHP 5.2+
 
 	public $regenerate			= 300;				//Update the session every five minutes (FALSE to disable)
 	public $expiration			= 7200;				//The session expires after 2 hours of non-use</diff>
      <filename>libraries/session.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a4c83cb2c5731da510c855ebeda3072b11e21239</id>
    </parent>
  </parents>
  <author>
    <name>Xeoncross</name>
    <email>david@xeoncross.com</email>
  </author>
  <url>http://github.com/Xeoncross/micromvc/commit/3f542c551aa1036eef6ee3eb3e89674c7bb1544e</url>
  <id>3f542c551aa1036eef6ee3eb3e89674c7bb1544e</id>
  <committed-date>2009-07-18T21:59:15-07:00</committed-date>
  <authored-date>2009-07-18T21:59:15-07:00</authored-date>
  <message>Fixed pagination function. Added new field_data() method based off of PDO to DB class. Fixed select() DB method. Fixed cookie path in sessions library.</message>
  <tree>ec9ceaaf63bd6505cf523b5a279fca1431764317</tree>
  <committer>
    <name>Xeoncross</name>
    <email>david@xeoncross.com</email>
  </committer>
</commit>
