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
c6f4dac2
Commit
c6f4dac2
authored
Sep 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored AR code.
parent
7303bae3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
ActiveRecord.php
framework/yii/db/ActiveRecord.php
+26
-26
No files found.
framework/yii/db/ActiveRecord.php
View file @
c6f4dac2
...
...
@@ -749,21 +749,21 @@ class ActiveRecord extends Model
return
false
;
}
$db
=
static
::
getDb
();
$transaction
=
$this
->
isTransactional
(
self
::
OP_INSERT
)
&&
$db
->
getTransaction
()
===
null
?
$db
->
beginTransaction
()
:
null
;
try
{
$result
=
$this
->
insertInternal
(
$attributes
);
if
(
$transaction
!==
null
)
{
if
(
$this
->
isTransactional
(
self
::
OP_INSERT
)
&&
$db
->
getTransaction
()
===
null
)
{
$transaction
=
$db
->
beginTransaction
();
try
{
$result
=
$this
->
insertInternal
(
$attributes
);
if
(
$result
===
false
)
{
$transaction
->
rollback
();
}
else
{
$transaction
->
commit
();
}
}
}
catch
(
\Exception
$e
)
{
if
(
$transaction
!==
null
)
{
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
throw
$e
;
}
else
{
$result
=
$this
->
insertInternal
(
$attributes
);
}
return
$result
;
}
...
...
@@ -859,21 +859,21 @@ class ActiveRecord extends Model
return
false
;
}
$db
=
static
::
getDb
();
$transaction
=
$this
->
isTransactional
(
self
::
OP_UPDATE
)
&&
$db
->
getTransaction
()
===
null
?
$db
->
beginTransaction
()
:
null
;
try
{
$result
=
$this
->
updateInternal
(
$attributes
);
if
(
$transaction
!==
null
)
{
if
(
$this
->
isTransactional
(
self
::
OP_UPDATE
)
&&
$db
->
getTransaction
()
===
null
)
{
$transaction
=
$db
->
beginTransaction
();
try
{
$result
=
$this
->
updateInternal
(
$attributes
);
if
(
$result
===
false
)
{
$transaction
->
rollback
();
}
else
{
$transaction
->
commit
();
}
}
}
catch
(
\Exception
$e
)
{
if
(
$transaction
!==
null
)
{
}
catch
(
\Exception
$e
)
{
$transaction
->
rollback
();
throw
$e
;
}
throw
$e
;
}
else
{
$result
=
$this
->
updateInternal
(
$attributes
);
}
return
$result
;
}
...
...
@@ -1010,6 +1010,16 @@ class ActiveRecord extends Model
}
/**
* Sets the value indicating whether the record is new.
* @param boolean $value whether the record is new and should be inserted when calling [[save()]].
* @see getIsNewRecord
*/
public
function
setIsNewRecord
(
$value
)
{
$this
->
_oldAttributes
=
$value
?
null
:
$this
->
_attributes
;
}
/**
* Initializes the object.
* This method is called at the end of the constructor.
* The default implementation will trigger an [[EVENT_INIT]] event.
...
...
@@ -1034,16 +1044,6 @@ class ActiveRecord extends Model
}
/**
* Sets the value indicating whether the record is new.
* @param boolean $value whether the record is new and should be inserted when calling [[save()]].
* @see getIsNewRecord
*/
public
function
setIsNewRecord
(
$value
)
{
$this
->
_oldAttributes
=
$value
?
null
:
$this
->
_attributes
;
}
/**
* This method is called at the beginning of inserting or updating a record.
* The default implementation will trigger an [[EVENT_BEFORE_INSERT]] event when `$insert` is true,
* or an [[EVENT_BEFORE_UPDATE]] event if `$insert` is false.
...
...
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