<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,8 @@
 &lt;?php
 
 // databases, list each one as a scheme://user:pass@host/db format
-// $db[] = 'mysql://root:root@localhost/test';
\ No newline at end of file
+// $db[] = 'mysql://root:root@localhost/test';
+
+// $properties['Class'] = array(
+//     ACTS_AS_MATERIALIZED_PATH =&gt; array('column'),
+// );
\ No newline at end of file</diff>
      <filename>config.dist.php</filename>
    </modified>
    <modified>
      <diff>@@ -13,3 +13,6 @@ define('TYPE_INT_AUTOINCREMENT', 3);
 define('RELATION_HASONE', 1);
 define('RELATION_HASMANY', 2);
 define('RELATION_HASMANYMANY', 3);
+
+// acts as
+define('ACTS_AS_MATERIALIZED_PATH', 1);
\ No newline at end of file</diff>
      <filename>lib/constants.php</filename>
    </modified>
    <modified>
      <diff>@@ -56,11 +56,12 @@ class SCAR_Repository {
         $this-&gt;is_initialized = true;
         
         $db = array();
+        $properties = array();
 
         if ($this-&gt;config_path === null &amp;&amp; count($this-&gt;db_list) == 0) {
             include SCAR_BASE.'config.php';
         }
-        elseif ($this-&gt;config_path === null) {
+        elseif ($this-&gt;config_path !== null) {
             include $this-&gt;config_path;
         }
         else {
@@ -97,7 +98,7 @@ class SCAR_Repository {
                                       'relates' =&gt; Inflector::camelize(substr($col, 0, -3)),
                     );
                 }
-                
+
                 // store
                 $this-&gt;scars[$klass_name] = $scar;
             }
@@ -119,6 +120,18 @@ class SCAR_Repository {
             // converse is also true
             $p-&gt;hasMany(Inflector::singularize(Inflector::classify($o-&gt;getTable())));
         }
+        
+        // add properties
+        foreach ($properties as $klass =&gt; $props) {
+            $scar =&amp; $this-&gt;scars[$klass];
+            foreach ($props as $type =&gt; $params) {
+                switch ($type) {
+                    case ACTS_AS_MATERIALIZED_PATH:
+                        $scar-&gt;actsAsMaterializedPath($params[0]);
+                        break;
+                }
+            }
+        }
     }
     
     public function get($klass) {</diff>
      <filename>lib/repository.php</filename>
    </modified>
    <modified>
      <diff>@@ -61,6 +61,8 @@ class SCAR_Generic implements Iterator {
         'set'           =&gt; array(),
         
         'scar'          =&gt; 'SCAR',
+        
+        'acts_as_materialized_path' =&gt; false,
     );
 
 
@@ -276,6 +278,101 @@ class SCAR_Generic implements Iterator {
         return (isset($this-&gt;_data['relations'][$klass])) ? $this-&gt;_data['relations'][$klass] : false;
     }
     
+    /**
+     * Says that this object acts with the Materialized Path pattern
+     * enables the calls for hasChildren and getChildren()
+     * @param string $col the column that contains path
+     * @return SCAR_Generic
+     **/
+    public function actsAsMaterializedPath($col) {
+        $this-&gt;_data['acts_as_materialized_path'] = $col;
+    }
+    
+    /**
+     * Says a boolean if this object supports children or not
+     * @return boolean
+     **/
+    public function hasChildren() {
+        return ($this-&gt;_data['acts_as_materialized_path']) ? true : false;
+    }
+    
+    /**
+     * get the children for this object based on the model type
+     * @return mixed SCAR_Generic or array()
+     **/
+    public function getChildren() {
+        if (!$this-&gt;hasChildren()) {
+            return array();
+        }
+        
+        // do sql
+        $this-&gt;doSQL();
+        
+        // if we don't know who we are, throw an exception
+        // can't multiplex children
+        if (!$this-&gt;whoAmI()) {
+            throw new SCAR_Method_Call_Exception('getChildren', $this);
+        }
+        
+        if ($this-&gt;_data['acts_as_materialized_path']) {
+            $scar = call_user_func_array(array($this-&gt;getSCAR(), 'get'), array($this-&gt;getName()));
+            $call = 'by' . Inflector::Camelize($this-&gt;_data['acts_as_materialized_path']);
+            $scar-&gt;$call('LIKE', $this-&gt;path.'%');
+            return $scar;
+        }
+    }
+    
+    /**
+     * looks at criteria to determine if a givnn object can have a parent
+     * @return boolean
+     **/
+    public function hasParent() {
+        if (!$this-&gt;_data['acts_as_materialized_path']) {
+            return false;
+        }
+        
+        // do SQL
+        $this-&gt;doSQL();
+        
+        // multiplex or 0 rows not valid
+        if (!$this-&gt;whoAmI()) {
+            return false;
+        }
+        
+        if (strrpos($this-&gt;path, '/', -2) === 0) {
+            return false;
+        }
+        
+        return true;
+    }
+    
+    /**
+     * get the parent for this object based on the nesting model types
+     * @return SCAR_Generic or false
+     **/
+    public function getParent() {
+        if (!$this-&gt;hasParent()) {
+            return false;
+        }
+        
+        // do sql
+        $this-&gt;doSQL();
+        
+        // if we don't know who we are, throw an exception
+        // can't multiplex children
+        if (!$this-&gt;whoAmI()) {
+            throw new SCAR_Method_Call_Exception('getParent', $this);
+        }
+        
+        if ($this-&gt;_data['acts_as_materialized_path']) {
+            $scar = call_user_func_array(array($this-&gt;getSCAR(), 'get'), array($this-&gt;getName()));
+            $call = 'by' . Inflector::Camelize($this-&gt;_data['acts_as_materialized_path']);
+            $path = substr($this-&gt;path, 0, strrpos($this-&gt;path, '/', -2) + 1);
+            var_dump($this-&gt;id.' '.$path);
+            $scar-&gt;$call($path); // path minus last node
+            return $scar;
+        }
+    }
 
     /**
      * Saves a SCAR object into the database</diff>
      <filename>lib/scargeneric.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3b7ae8e6a592a2008f20583a819e7449fc5f8a36</id>
    </parent>
  </parents>
  <author>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </author>
  <url>http://github.com/Jakobo/scar/commit/ae0c9a755d59771ebcf56b5e694b60911de6916e</url>
  <id>ae0c9a755d59771ebcf56b5e694b60911de6916e</id>
  <committed-date>2008-05-15T03:10:16-07:00</committed-date>
  <authored-date>2008-05-15T03:10:16-07:00</authored-date>
  <message>ActsAsMaterializedPath support added, basic nesting framework in place</message>
  <tree>93f70e2ce30d08f25b9b86dc0a8b21226aa0e1ac</tree>
  <committer>
    <name>Jakob Heuser</name>
    <email>jakob@felocity.org</email>
  </committer>
</commit>
