<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>init.php</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -64,18 +64,48 @@
 		# add one or more has_many relations to the object, usually run inside the
 		# setup method
 		function has_many($what, $options) {
+			$table = Inflector::tableize($what);
+			$default_options = array(
+				&quot;class_name&quot; =&gt; Inflector::classify($table),
+				&quot;primary_key&quot; =&gt; &quot;id&quot;,
+				&quot;foreign_key&quot; =&gt; Inflector::singularize($this-&gt;_base_class) . &quot;_id&quot;,
+				&quot;dependent&quot; =&gt; &quot;nullify&quot;,
+				&quot;uniq&quot; =&gt; false
+				&quot;select&quot; =&gt; &quot;*&quot;,
+				&quot;validate&quot; =&gt; true
+			);
+			$options = array_merge($default_options, $options);
 			$this-&gt;_has_many = array_merge($this-&gt;_has_many, array($what =&gt; $options));
 		}
 
 		# add one or more has_one relations to the object, usually run inside the
 		# setup method
 		function has_one($what, $options) {
+			$table = Inflector::tableize($what);
+			$default_options = array(
+				&quot;class_name&quot; =&gt; Inflector::classify($table),
+				&quot;primary_key&quot; =&gt; &quot;id&quot;,
+				&quot;foreign_key&quot; =&gt; Inflector::singularize($this-&gt;_base_class) . &quot;_id&quot;,
+				&quot;dependent&quot; =&gt; &quot;nullify&quot;,
+				&quot;select&quot; =&gt; &quot;*&quot;,
+				&quot;validate&quot; =&gt; true
+			);
+			$options = array_merge($default_options, $options);
 			$this-&gt;_has_one = array_merge($this-&gt;_has_one, array($what =&gt; $options));
 		}
 
 		# add one or more belongs_to relations to the object, usually run inside the
 		# setup method
 		function belongs_to($what, $options) {
+			$table = Inflector::tableize($what);
+			$default_options = array(
+				&quot;class_name&quot; =&gt; Inflector::classify($table),
+				&quot;foreign_key&quot; =&gt; Inflector::singularize($table) . &quot;_id&quot;,
+				&quot;polymorphic&quot; =&gt; false,
+				&quot;select&quot; =&gt; &quot;*&quot;,
+				&quot;validate&quot; =&gt; false
+			);
+			$options = array_merge($default_options, $options);
 			$this-&gt;_belongs_to = array_merge($this-&gt;_belongs_to, array($what =&gt; $options));
 		}
 </diff>
      <filename>lib/AdoDBRecord.class.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,6 +18,7 @@
 
 	require_once(&quot;BaseImplementer.class.php&quot;);
 	require_once(&quot;Tools.module.php&quot;);
+	require_once(&quot;Inflector.class.php&quot;);
 
 	# class to polymorphically implement AdoDBRecord functionality
 	# This makes use of PHP's behaviour to always pass the $this variable
@@ -87,6 +88,7 @@
 		# as an instance or array of instances of $class
 		function &amp;find($arguments) {
 			$conditions = array();
+			# TODO preset from scoped options
 			$where = $order = $limit = $offset = NULL;
 			$options = array();
 
@@ -141,6 +143,7 @@
 			}
 
 			# parse conditions
+			# TODO join with scoped conditions
 			$parsed_conditions = array();
 			$parsed_params = array();
 			AdoDBRecord_Tools::parse_conditions($conditions, $parsed_conditions, $parsed_params);</diff>
      <filename>lib/AdoDBRecord/Base.class.php</filename>
    </modified>
    <modified>
      <diff>@@ -10,7 +10,8 @@
 	#
 	# This file holds some tools for initialization and configuration
 
-	require_once(&quot;../lib/Singleton.class.php&quot;);
+	require_once(&quot;Singleton.class.php&quot;);
+	require_once(&quot;Inflector.class.php&quot;);
 
 	# Helper function to return a global database connection to AdoDB
 	function &amp;_adodb_conn() {
@@ -96,22 +97,22 @@
 
 		# check if the named property is part of a has_many association
 		function is_has_many_property($name) {
-			return array_key_exists($property, $this-&gt;_has_many);
+			return array_key_exists($name, $this-&gt;_has_many);
 		}
 
 		# check if the named property is part of a has_one association
 		function is_has_one_property($name) {
-			return array_key_exists($property, $this-&gt;_has_one);
+			return array_key_exists($name, $this-&gt;_has_one);
 		}
 
 		# check if the named property is part of a has_many association
 		function is_belongs_to_property($name) {
-			return array_key_exists($property, $this-&gt;_belongs_to);
+			return array_key_exists($name, $this-&gt;_belongs_to);
 		}
 
 		# check if the named property is part of any association
 		function is_association_property($name) {
-			return is_belongs_to_property($name) || is_has_many_property($name) || is_has_one_property($name)
+			return is_belongs_to_property($name) || is_has_many_property($name) || is_has_one_property($name);
 		}
 	}
-?&gt;
+?&gt;
\ No newline at end of file</diff>
      <filename>lib/AdoDBRecord/Tools.module.php</filename>
    </modified>
    <modified>
      <diff>@@ -60,6 +60,22 @@
 			return strtolower($string);
 		}
 
+		# converts underscores to camel case
+		function camelize($string, $first_letter_in_uppercase = true) {
+			if ($first_letter_in_uppercase)
+			{
+				$string = preg_replace_callback('/\/(.?)/', create_function('$m', 'return &quot;::&quot; . strtoupper($m[1]);'), $string);
+				return preg_replace_callback('/(?:^|_)(.)/', create_function('$m', 'return strtoupper($m[1]);'), $string);
+			}
+			else
+				return strtolower($string[0]) . Inflector::camelize(substr($string, 1));
+		}
+
+		# converts table name to class name
+		function classify($string) {
+			return str_replace('::', '_', Inflector::camelize(Inflector::singularize(preg_replace('/^.*\./', '', $string))));
+		}
+
 		# converts class name to table name
 		function tableize($string) {
 			return Inflector::pluralize(Inflector::underscore($string));</diff>
      <filename>lib/Inflector.class.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1bf2ebce4629e65141964575c39c517834320993</id>
    </parent>
  </parents>
  <author>
    <name>Kai Krakow</name>
    <email>kk@netactive.de</email>
  </author>
  <url>http://github.com/kakra/adodbrecord/commit/4300b571dfc6f77d696ae63bc3665b9d8914ae46</url>
  <id>4300b571dfc6f77d696ae63bc3665b9d8914ae46</id>
  <committed-date>2009-01-28T09:17:47-08:00</committed-date>
  <authored-date>2009-01-28T09:17:47-08:00</authored-date>
  <message>Create inflectors needed for associations

This creates inflector methods to derive the class name from a
camel_cased name which is needed for creating the association options.

Also added an init.php for easier loading of the library. It sets
some defaults and changes the include path correctly.

Using the new inflector methods the default options of associations
are now set. Next step is doing the wrappers (marked relevant code
parts with TODO).</message>
  <tree>f1cda6dbefb665ef0afa57f405639bb0790cd496</tree>
  <committer>
    <name>Kai Krakow</name>
    <email>kk@netactive.de</email>
  </committer>
</commit>
