Skip to content

Commit

Permalink
Correcting and improving doc block for Model::__construct.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 2, 2010
1 parent 3c88d81 commit 026eeb6
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions cake/libs/model/model.php
Expand Up @@ -333,9 +333,34 @@ class Model extends Overloadable {
/**
* Constructor. Binds the model's database table to the object.
*
* @param integer $id Set this ID for this model on startup
* If `$id` is an array it can be used to pass several options into the model.
*
* - id - The id to start the model on.
* - table - The table to use for this model.
* - ds - The connection name this model is connected to.
* - name - The name of the model eg. Post.
* - alias - The alias of the model, this is used for registering the instance in the `ClassRegistry`.
* eg. `ParentThread`
*
* ### Overriding Model's __construct method.
*
* When overriding Model::__construct() be careful to include and pass in all 3 of the
* arguments to `parent::__construct($id, $table, $ds);`
*
* ### Dynamically creating models
*
* You can dynamically create model instances using the the $id array syntax.
*
* {{{
* $Post = new Model(array('table' => 'posts', 'name' => 'Post', 'ds' => 'connection2'));
* }}}
*
* Would create a model attached to the posts table on connection2. Dynamic model creation is useful
* when you want a model object that contains no associations or attached behaviors.
*
* @param mixed $id Set this ID for this model on startup, can also be an array of options, see above.
* @param string $table Name of database table to use.
* @param object $ds DataSource connection object.
* @param string $ds DataSource connection name.
*/
function __construct($id = false, $table = null, $ds = null) {
parent::__construct();
Expand Down

0 comments on commit 026eeb6

Please sign in to comment.