Adding optional $data parameter to Model::create(), allowing default data to be set when initializing a model

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3302 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2006-07-27 04:10:41 +00:00
parent 71a119ba3d
commit cd3578e0b4
2 changed files with 13 additions and 2 deletions

View file

@ -770,7 +770,7 @@ class Model extends Object{
*
* @return boolean True
*/
function create() {
function create($data = null) {
$this->id = false;
unset ($this->data);
$this->data = array();
@ -784,6 +784,11 @@ class Model extends Object{
}
}
}
if (!empty($data) && $data !== null) {
$this->set($data);
}
return true;
}
/**

View file

@ -762,9 +762,10 @@ class Model extends Object {
/**
* Initializes the model for writing a new record.
*
* @param array $data Optional data to assign to the model after it is created
* @return boolean True
*/
function create() {
function create($data = null) {
$this->id = false;
unset ($this->data);
$this->data = array();
@ -778,6 +779,11 @@ class Model extends Object {
}
}
}
if (!empty($data) && $data !== null) {
$this->set($data);
}
return true;
}
/**