Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Yeray Santana Hualde
syncEnrollments
Commits
285cdcc8
Commit
285cdcc8
authored
Jun 14, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug when deleting eloquent models.
parent
05b2e287
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
2 deletions
+41
-2
eloquent.php
system/db/eloquent.php
+29
-1
warehouse.php
system/db/eloquent/warehouse.php
+12
-1
No files found.
system/db/eloquent.php
View file @
285cdcc8
...
...
@@ -178,12 +178,40 @@ abstract class Eloquent {
*/
public
function
save
()
{
// -----------------------------------------------------
// If the model doesn't have any dirty attributes, there
// is no need to save it to the database.
// -----------------------------------------------------
if
(
$this
->
exists
and
count
(
$this
->
dirty
)
==
0
)
{
return
true
;
}
return
Eloquent\Warehouse
::
store
(
$this
);
$result
=
Eloquent\Warehouse
::
put
(
$this
);
// -----------------------------------------------------
// The dirty attributes can be cleared after each save.
// -----------------------------------------------------
$this
->
dirty
=
array
();
return
$result
;
}
/**
* Delete a model from the database.
*/
public
function
delete
(
$id
=
null
)
{
// -----------------------------------------------------
// If the method is being called from an existing model,
// only delete that model from the database.
// -----------------------------------------------------
if
(
$this
->
exists
)
{
return
Eloquent\Warehouse
::
forget
(
$this
);
}
return
$this
->
query
->
delete
(
$id
);
}
/**
...
...
system/db/eloquent/warehouse.php
View file @
285cdcc8
...
...
@@ -8,7 +8,7 @@ class Warehouse {
* @param object $eloquent
* @return bool
*/
public
static
function
store
(
$eloquent
)
public
static
function
put
(
$eloquent
)
{
$model
=
get_class
(
$eloquent
);
...
...
@@ -39,6 +39,17 @@ class Warehouse {
return
true
;
}
/**
* Delete an Eloquent model from the database.
*
* @param object $eloquent
* @return bool
*/
public
static
function
forget
(
$eloquent
)
{
return
(
\System\DB
::
table
(
Meta
::
table
(
get_class
(
$eloquent
)))
->
where
(
'id'
,
'='
,
$eloquent
->
id
)
->
delete
()
==
1
);
}
/**
* Set the activity timestamps on a model.
*
...
...
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