mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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:
parent
71a119ba3d
commit
cd3578e0b4
2 changed files with 13 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue