From 026eeb645b6959115bacd0bf690db9edfb5ac167 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Fri, 1 Jan 2010 23:58:07 -0500 Subject: [PATCH] Correcting and improving doc block for Model::__construct. --- cake/libs/model/model.php | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/cake/libs/model/model.php b/cake/libs/model/model.php index f0e0a6e9c4b..c7fd52c6c6d 100644 --- a/cake/libs/model/model.php +++ b/cake/libs/model/model.php @@ -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();