Skip to content

Commit

Permalink
Merge branch 'develop' into feature/kohana-3.1
Browse files Browse the repository at this point in the history
Conflicts:
	classes/auth/automodeler/orm.php
	classes/automodeler.php
	classes/automodeler/core.php
	classes/automodeler/orm.php
	classes/automodeler/orm/core.php
	guide/auto-modeler/automodeler.md
	guide/auto-modeler/index.md
  • Loading branch information
zombor committed Mar 28, 2011
2 parents fa25c6d + cd75190 commit b92418b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 21 deletions.
2 changes: 1 addition & 1 deletion classes/auth/automodeler/orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,4 @@ public function check_password($password)
return $hash == $user->password;
}

} // End Auth ORM
} // End Auth ORM
2 changes: 1 addition & 1 deletion classes/automodeler.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
class AutoModeler extends AutoModeler_Core
{

}
}
63 changes: 48 additions & 15 deletions classes/automodeler/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ class AutoModeler_Core extends Model_Database implements ArrayAccess
);

/**
* Standard constructor, accepts an `id` column to look for
* The constructor enables you to either create an empty object when no
* parameter is passed as $id, or it fetches a row when the parameter
* is passed.
*
* $blog_entry = new Blog_Model(5);
*
* @param string $id an id to search for
*
Expand Down Expand Up @@ -158,7 +162,10 @@ public function process_load_state()
}

/**
* Magic get method, gets model properties from the db
* Retrieve items from the $data array.
*
* <h1><?=$blog_entry->title?></h1>
* <p><?=$blog_entry->content?></p>
*
* @param string $key the field name to look for
*
Expand All @@ -175,7 +182,11 @@ public function __get($key)
}

/**
* Magic get method, set model properties to the model
* Set the items in the $data array.
*
* $blog_entry = new Model_Blog;
* $blog_entry->title = 'Demo';
* $blog_entry->content = 'My awesome content';
*
* @param string $key the field name to set
* @param string $value the value to set to
Expand All @@ -193,7 +204,6 @@ public function __set($key, $value)
}

Log::instance()->add(Log::ERROR, 'Field '.$key.' does not exist in '.get_class($this).'!');
throw new AutoModeler_Exception('Field '.$key.' does not exist in '.get_class($this).'!', array(), '');
}

/**
Expand Down Expand Up @@ -242,7 +252,7 @@ public function state($state = NULL)
}

/**
* Gets an array version of the model
* Gets an array version of the model.
*
* @return array
*/
Expand All @@ -262,7 +272,10 @@ public function get_table_name()
}

/**
* Useful for chaining
* The factory method returns a model instance of the model name provided.
* You can also specify an id to create a specific object. Works similar to
* ORM::factory(). Using this, you can chain methods off models that
* shouldn't be instantiated.
*
* @param string $model the model name
* @param int $id an id to pass to the constructor
Expand All @@ -276,9 +289,12 @@ public static function factory($model, $id = NULL)
}

/**
* Mass sets object properties
* Mass sets object properties. Never pass $_POST into this method directly.
* Always use something like array_key_intersect() to filter the array.
*
* @param array $data the data to set
*
* @return null
*
*/
public function set_fields(array $data)
Expand All @@ -290,7 +306,8 @@ public function set_fields(array $data)
}

/**
* Returns errors for this model
* Behaves the same as the validation object's errors() method.
* Use it to retrieve an array of validation errors from the current object.
*
* @param string $lang the messages file to use
*
Expand All @@ -302,11 +319,20 @@ public function errors($lang = NULL)
}

/**
* Determines the validity of this object
* Performs the validation on your model. You can use this before you save
* to ensure the model is valid. save() will call this method internally.
*
* You can pass an existing validation object into this method.
*
* Returns either TRUE on success, or an array that contains a html version
* of the errors and the raw errors array from the validation object.
*
* @param mixed $validation a manual validation object to combine the model properties with
* @param mixed $validation a manual validation object to combine the model
* properties with
*
* @return mixed
* @return TRUE on success
* @return array with keys 'string' containing an html list of errors and
* 'errors', the raw errors validation object
*/
public function is_valid($validation = NULL)
{
Expand All @@ -333,7 +359,9 @@ public function is_valid($validation = NULL)
}

/**
* Saves the current object
* Saves the model to your database. If $data['id'] is empty, it will do a
* database INSERT and assign the inserted row id to $data['id'].
* If $data['id'] is not empty, it will do a database UPDATE.
*
* @param mixed $validation a manual validation object to combine the model properties with
*
Expand Down Expand Up @@ -366,7 +394,8 @@ public function save($validation = NULL)
}

/**
* Deletes the current object from the database
* Deletes the current object's associated database row.
* The object will still contain valid data until it is destroyed.
*
* @return integer
*/
Expand All @@ -383,7 +412,10 @@ public function delete()
}

/**
* Get a nice array for form::dropdown()
* Returns an associative array, where the keys of the array is set to $key
* column of each row, and the value is set to the $display column.
* You can optionally specify the $query parameter to pass to filter for
* different data.
*
* @param array $key the key to use for the array
* @param array $where the value to use for the display
Expand Down Expand Up @@ -435,7 +467,8 @@ public function select_list($key, $display, Database_Query_Builder_Select $query
}

/**
* Returns all the columns in this model
* Returns an array of the columns in this object.
* Useful for db::select_array().
*
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion classes/automodeler/orm.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
class AutoModeler_ORM extends AutoModeler_ORM_Core
{

}
}
4 changes: 2 additions & 2 deletions classes/automodeler/orm/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function relate($key, array $values)
}

/**
* Finds many to many relationships
* Finds relations of a has_many relationship
*
* // Finds all roles belonging to a user
* $user->find_related('roles');
Expand Down Expand Up @@ -331,7 +331,7 @@ public function has($key, $value)
}

/**
* Removes a relationship if you aren't using innoDB (shame on you!)
* Removes a has_many relationship if you aren't using innoDB (shame on you!)
*
* Model must have a _has_many relationship with the other model, which is
* passed as the first parameter in plural form without the Model_ prefix.
Expand Down
6 changes: 5 additions & 1 deletion guide/auto-modeler/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<<<<<<< HEAD
# AutoModeler Documentation

Click the menu to view each section.
Click the menu to view each section.
=======
bar
>>>>>>> develop

0 comments on commit b92418b

Please sign in to comment.