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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
fa767cea
Commit
fa767cea
authored
Apr 09, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed attributes to attributeNames in model
fixes #3034
parent
3fdcf11f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
31 deletions
+30
-31
ActiveRecord.php
extensions/sphinx/ActiveRecord.php
+5
-5
Model.php
framework/base/Model.php
+8
-9
ActiveRecord.php
framework/db/ActiveRecord.php
+5
-5
ActiveRecordInterface.php
framework/db/ActiveRecordInterface.php
+4
-4
BaseActiveRecord.php
framework/db/BaseActiveRecord.php
+8
-8
No files found.
extensions/sphinx/ActiveRecord.php
View file @
fa767cea
...
@@ -443,7 +443,7 @@ abstract class ActiveRecord extends BaseActiveRecord
...
@@ -443,7 +443,7 @@ abstract class ActiveRecord extends BaseActiveRecord
*
*
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be inserted into the database.
* If the validation fails, the record will not be inserted into the database.
* @param array $attributes list of attributes that need to be saved. Defaults to null,
* @param array $attribute
Name
s list of attributes that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return integer|boolean the number of rows affected, or false if validation fails
* @return integer|boolean the number of rows affected, or false if validation fails
* or [[beforeSave()]] stops the updating process.
* or [[beforeSave()]] stops the updating process.
...
@@ -451,16 +451,16 @@ abstract class ActiveRecord extends BaseActiveRecord
...
@@ -451,16 +451,16 @@ abstract class ActiveRecord extends BaseActiveRecord
* being updated is outdated.
* being updated is outdated.
* @throws \Exception in case update failed.
* @throws \Exception in case update failed.
*/
*/
public
function
update
(
$runValidation
=
true
,
$attributes
=
null
)
public
function
update
(
$runValidation
=
true
,
$attribute
Name
s
=
null
)
{
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attributes
))
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attribute
Name
s
))
{
return
false
;
return
false
;
}
}
$db
=
static
::
getDb
();
$db
=
static
::
getDb
();
if
(
$this
->
isTransactional
(
self
::
OP_UPDATE
)
&&
$db
->
getTransaction
()
===
null
)
{
if
(
$this
->
isTransactional
(
self
::
OP_UPDATE
)
&&
$db
->
getTransaction
()
===
null
)
{
$transaction
=
$db
->
beginTransaction
();
$transaction
=
$db
->
beginTransaction
();
try
{
try
{
$result
=
$this
->
updateInternal
(
$attributes
);
$result
=
$this
->
updateInternal
(
$attribute
Name
s
);
if
(
$result
===
false
)
{
if
(
$result
===
false
)
{
$transaction
->
rollBack
();
$transaction
->
rollBack
();
}
else
{
}
else
{
...
@@ -471,7 +471,7 @@ abstract class ActiveRecord extends BaseActiveRecord
...
@@ -471,7 +471,7 @@ abstract class ActiveRecord extends BaseActiveRecord
throw
$e
;
throw
$e
;
}
}
}
else
{
}
else
{
$result
=
$this
->
updateInternal
(
$attributes
);
$result
=
$this
->
updateInternal
(
$attribute
Name
s
);
}
}
return
$result
;
return
$result
;
...
...
framework/base/Model.php
View file @
fa767cea
...
@@ -302,14 +302,14 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -302,14 +302,14 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
* Errors found during the validation can be retrieved via [[getErrors()]],
* Errors found during the validation can be retrieved via [[getErrors()]],
* [[getFirstErrors()]] and [[getFirstError()]].
* [[getFirstErrors()]] and [[getFirstError()]].
*
*
* @param array $attribute
s list of attribut
es that should be validated.
* @param array $attribute
Names list of attribute nam
es that should be validated.
* If this parameter is empty, it means any attribute listed in the applicable
* If this parameter is empty, it means any attribute listed in the applicable
* validation rules should be validated.
* validation rules should be validated.
* @param boolean $clearErrors whether to call [[clearErrors()]] before performing validation
* @param boolean $clearErrors whether to call [[clearErrors()]] before performing validation
* @return boolean whether the validation is successful without any error.
* @return boolean whether the validation is successful without any error.
* @throws InvalidParamException if the current scenario is unknown.
* @throws InvalidParamException if the current scenario is unknown.
*/
*/
public
function
validate
(
$attributes
=
null
,
$clearErrors
=
true
)
public
function
validate
(
$attribute
Name
s
=
null
,
$clearErrors
=
true
)
{
{
$scenarios
=
$this
->
scenarios
();
$scenarios
=
$this
->
scenarios
();
$scenario
=
$this
->
getScenario
();
$scenario
=
$this
->
getScenario
();
...
@@ -320,12 +320,12 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -320,12 +320,12 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
if
(
$clearErrors
)
{
if
(
$clearErrors
)
{
$this
->
clearErrors
();
$this
->
clearErrors
();
}
}
if
(
$attributes
===
null
)
{
if
(
$attribute
Name
s
===
null
)
{
$attributes
=
$this
->
activeAttributes
();
$attribute
Name
s
=
$this
->
activeAttributes
();
}
}
if
(
$this
->
beforeValidate
())
{
if
(
$this
->
beforeValidate
())
{
foreach
(
$this
->
getActiveValidators
()
as
$validator
)
{
foreach
(
$this
->
getActiveValidators
()
as
$validator
)
{
$validator
->
validateAttributes
(
$this
,
$attributes
);
$validator
->
validateAttributes
(
$this
,
$attribute
Name
s
);
}
}
$this
->
afterValidate
();
$this
->
afterValidate
();
...
@@ -791,18 +791,18 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -791,18 +791,18 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
* This method will validate every model. The models being validated may
* This method will validate every model. The models being validated may
* be of the same or different types.
* be of the same or different types.
* @param array $models the models to be validated
* @param array $models the models to be validated
* @param array $attribute
s list of attribut
es that should be validated.
* @param array $attribute
Names list of attribute nam
es that should be validated.
* If this parameter is empty, it means any attribute listed in the applicable
* If this parameter is empty, it means any attribute listed in the applicable
* validation rules should be validated.
* validation rules should be validated.
* @return boolean whether all models are valid. False will be returned if one
* @return boolean whether all models are valid. False will be returned if one
* or multiple models have validation error.
* or multiple models have validation error.
*/
*/
public
static
function
validateMultiple
(
$models
,
$attributes
=
null
)
public
static
function
validateMultiple
(
$models
,
$attribute
Name
s
=
null
)
{
{
$valid
=
true
;
$valid
=
true
;
/** @var Model $model */
/** @var Model $model */
foreach
(
$models
as
$model
)
{
foreach
(
$models
as
$model
)
{
$valid
=
$model
->
validate
(
$attributes
)
&&
$valid
;
$valid
=
$model
->
validate
(
$attribute
Name
s
)
&&
$valid
;
}
}
return
$valid
;
return
$valid
;
...
@@ -906,7 +906,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
...
@@ -906,7 +906,6 @@ class Model extends Component implements IteratorAggregate, ArrayAccess, Arrayab
public
function
getIterator
()
public
function
getIterator
()
{
{
$attributes
=
$this
->
getAttributes
();
$attributes
=
$this
->
getAttributes
();
return
new
ArrayIterator
(
$attributes
);
return
new
ArrayIterator
(
$attributes
);
}
}
...
...
framework/db/ActiveRecord.php
View file @
fa767cea
...
@@ -480,7 +480,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -480,7 +480,7 @@ class ActiveRecord extends BaseActiveRecord
*
*
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be inserted into the database.
* If the validation fails, the record will not be inserted into the database.
* @param array $attributes list of attributes that need to be saved. Defaults to null,
* @param array $attribute
Name
s list of attributes that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return integer|boolean the number of rows affected, or false if validation fails
* @return integer|boolean the number of rows affected, or false if validation fails
* or [[beforeSave()]] stops the updating process.
* or [[beforeSave()]] stops the updating process.
...
@@ -488,9 +488,9 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -488,9 +488,9 @@ class ActiveRecord extends BaseActiveRecord
* being updated is outdated.
* being updated is outdated.
* @throws \Exception in case update failed.
* @throws \Exception in case update failed.
*/
*/
public
function
update
(
$runValidation
=
true
,
$attributes
=
null
)
public
function
update
(
$runValidation
=
true
,
$attribute
Name
s
=
null
)
{
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attributes
))
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attribute
Name
s
))
{
Yii
::
info
(
'Model not updated due to validation error.'
,
__METHOD__
);
Yii
::
info
(
'Model not updated due to validation error.'
,
__METHOD__
);
return
false
;
return
false
;
}
}
...
@@ -498,7 +498,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -498,7 +498,7 @@ class ActiveRecord extends BaseActiveRecord
if
(
$this
->
isTransactional
(
self
::
OP_UPDATE
))
{
if
(
$this
->
isTransactional
(
self
::
OP_UPDATE
))
{
$transaction
=
$db
->
beginTransaction
();
$transaction
=
$db
->
beginTransaction
();
try
{
try
{
$result
=
$this
->
updateInternal
(
$attributes
);
$result
=
$this
->
updateInternal
(
$attribute
Name
s
);
if
(
$result
===
false
)
{
if
(
$result
===
false
)
{
$transaction
->
rollBack
();
$transaction
->
rollBack
();
}
else
{
}
else
{
...
@@ -509,7 +509,7 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -509,7 +509,7 @@ class ActiveRecord extends BaseActiveRecord
throw
$e
;
throw
$e
;
}
}
}
else
{
}
else
{
$result
=
$this
->
updateInternal
(
$attributes
);
$result
=
$this
->
updateInternal
(
$attribute
Name
s
);
}
}
return
$result
;
return
$result
;
...
...
framework/db/ActiveRecordInterface.php
View file @
fa767cea
...
@@ -272,11 +272,11 @@ interface ActiveRecordInterface
...
@@ -272,11 +272,11 @@ interface ActiveRecordInterface
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be saved to database. `false` will be returned
* If the validation fails, the record will not be saved to database. `false` will be returned
* in this case.
* in this case.
* @param array $attributes list of attributes that need to be saved. Defaults to null,
* @param array $attribute
Name
s list of attributes that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return boolean whether the saving succeeds
* @return boolean whether the saving succeeds
*/
*/
public
function
save
(
$runValidation
=
true
,
$attributes
=
null
);
public
function
save
(
$runValidation
=
true
,
$attribute
Name
s
=
null
);
/**
/**
* Inserts the record into the database using the attribute values of this record.
* Inserts the record into the database using the attribute values of this record.
...
@@ -312,14 +312,14 @@ interface ActiveRecordInterface
...
@@ -312,14 +312,14 @@ interface ActiveRecordInterface
*
*
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be inserted into the database.
* If the validation fails, the record will not be inserted into the database.
* @param array $attributes list of attributes that need to be saved. Defaults to null,
* @param array $attribute
Name
s list of attributes that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return integer|boolean the number of rows affected, or false if validation fails
* @return integer|boolean the number of rows affected, or false if validation fails
* or updating process is stopped for other reasons.
* or updating process is stopped for other reasons.
* Note that it is possible that the number of rows affected is 0, even though the
* Note that it is possible that the number of rows affected is 0, even though the
* update execution is successful.
* update execution is successful.
*/
*/
public
function
update
(
$runValidation
=
true
,
$attributes
=
null
);
public
function
update
(
$runValidation
=
true
,
$attribute
Name
s
=
null
);
/**
/**
* Deletes the record from the database.
* Deletes the record from the database.
...
...
framework/db/BaseActiveRecord.php
View file @
fa767cea
...
@@ -565,16 +565,16 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -565,16 +565,16 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*
*
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be saved to database.
* If the validation fails, the record will not be saved to database.
* @param array $attribute
s list of attribut
es that need to be saved. Defaults to null,
* @param array $attribute
Names list of attribute nam
es that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return boolean whether the saving succeeds
* @return boolean whether the saving succeeds
*/
*/
public
function
save
(
$runValidation
=
true
,
$attributes
=
null
)
public
function
save
(
$runValidation
=
true
,
$attribute
Name
s
=
null
)
{
{
if
(
$this
->
getIsNewRecord
())
{
if
(
$this
->
getIsNewRecord
())
{
return
$this
->
insert
(
$runValidation
,
$attributes
);
return
$this
->
insert
(
$runValidation
,
$attribute
Name
s
);
}
else
{
}
else
{
return
$this
->
update
(
$runValidation
,
$attributes
)
!==
false
;
return
$this
->
update
(
$runValidation
,
$attribute
Name
s
)
!==
false
;
}
}
}
}
...
@@ -620,7 +620,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -620,7 +620,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
*
*
* @param boolean $runValidation whether to perform validation before saving the record.
* @param boolean $runValidation whether to perform validation before saving the record.
* If the validation fails, the record will not be inserted into the database.
* If the validation fails, the record will not be inserted into the database.
* @param array $attribute
s list of attribut
es that need to be saved. Defaults to null,
* @param array $attribute
Names list of attribute nam
es that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* meaning all attributes that are loaded from DB will be saved.
* @return integer|boolean the number of rows affected, or false if validation fails
* @return integer|boolean the number of rows affected, or false if validation fails
* or [[beforeSave()]] stops the updating process.
* or [[beforeSave()]] stops the updating process.
...
@@ -628,12 +628,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
...
@@ -628,12 +628,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
* being updated is outdated.
* being updated is outdated.
* @throws \Exception in case update failed.
* @throws \Exception in case update failed.
*/
*/
public
function
update
(
$runValidation
=
true
,
$attributes
=
null
)
public
function
update
(
$runValidation
=
true
,
$attribute
Name
s
=
null
)
{
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attributes
))
{
if
(
$runValidation
&&
!
$this
->
validate
(
$attribute
Name
s
))
{
return
false
;
return
false
;
}
}
return
$this
->
updateInternal
(
$attributes
);
return
$this
->
updateInternal
(
$attribute
Name
s
);
}
}
/**
/**
...
...
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