Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
e9d7a220
Commit
e9d7a220
authored
Jun 22, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #576 from creocoder/ar-set-attribute
ActiveRecord::setAttribute() bugfix
parents
6c5dfc04
bb2e19fa
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+10
-0
No files found.
framework/yii/db/ActiveRecord.php
View file @
e9d7a220
...
@@ -523,11 +523,16 @@ class ActiveRecord extends Model
...
@@ -523,11 +523,16 @@ class ActiveRecord extends Model
* Sets the named attribute value.
* Sets the named attribute value.
* @param string $name the attribute name
* @param string $name the attribute name
* @param mixed $value the attribute value.
* @param mixed $value the attribute value.
* @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute
* @see hasAttribute
*/
*/
public
function
setAttribute
(
$name
,
$value
)
public
function
setAttribute
(
$name
,
$value
)
{
{
if
(
isset
(
$this
->
_attributes
[
$name
])
||
isset
(
$this
->
getTableSchema
()
->
columns
[
$name
]))
{
$this
->
_attributes
[
$name
]
=
$value
;
$this
->
_attributes
[
$name
]
=
$value
;
}
else
{
throw
new
InvalidParamException
(
get_class
(
$this
)
.
' has no attribute named "'
.
$name
.
'".'
);
}
}
}
/**
/**
...
@@ -567,11 +572,16 @@ class ActiveRecord extends Model
...
@@ -567,11 +572,16 @@ class ActiveRecord extends Model
* Sets the old value of the named attribute.
* Sets the old value of the named attribute.
* @param string $name the attribute name
* @param string $name the attribute name
* @param mixed $value the old attribute value.
* @param mixed $value the old attribute value.
* @throws InvalidParamException if the named attribute does not exist.
* @see hasAttribute
* @see hasAttribute
*/
*/
public
function
setOldAttribute
(
$name
,
$value
)
public
function
setOldAttribute
(
$name
,
$value
)
{
{
if
(
isset
(
$this
->
_oldAttributes
[
$name
])
||
isset
(
$this
->
getTableSchema
()
->
columns
[
$name
]))
{
$this
->
_oldAttributes
[
$name
]
=
$value
;
$this
->
_oldAttributes
[
$name
]
=
$value
;
}
else
{
throw
new
InvalidParamException
(
get_class
(
$this
)
.
' has no attribute named "'
.
$name
.
'".'
);
}
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment