Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
eca4f7a1
Commit
eca4f7a1
authored
Sep 24, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added delete functionality to records.
parent
6d6f6c75
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
12 deletions
+41
-12
Collection.php
lib/Doctrine/Resource/Collection.php
+7
-0
Record.php
lib/Doctrine/Resource/Record.php
+14
-0
Server.php
lib/Doctrine/Resource/Server.php
+16
-11
index.php
playground/index.php
+4
-1
No files found.
lib/Doctrine/Resource/Collection.php
View file @
eca4f7a1
...
...
@@ -104,4 +104,11 @@ class Doctrine_Resource_Collection extends Doctrine_Resource_Access implements C
$record
->
save
();
}
}
public
function
delete
()
{
foreach
(
$this
as
$record
)
{
$record
->
delete
();
}
}
}
lib/Doctrine/Resource/Record.php
View file @
eca4f7a1
...
...
@@ -169,6 +169,7 @@ class Doctrine_Resource_Record extends Doctrine_Resource_Access implements Count
$request
->
set
(
'type'
,
'save'
);
$request
->
set
(
'model'
,
$this
->
getModel
());
$request
->
set
(
'data'
,
$this
->
getChanges
());
$request
->
set
(
'identifier'
,
$this
->
identifier
());
$response
=
$request
->
execute
();
...
...
@@ -177,6 +178,19 @@ class Doctrine_Resource_Record extends Doctrine_Resource_Access implements Count
$this
->
_data
=
$request
->
hydrate
(
array
(
$array
),
$this
->
_model
)
->
getFirst
()
->
_data
;
}
public
function
delete
()
{
$format
=
$this
->
getConfig
(
'format'
);
$request
=
new
Doctrine_Resource_Request
();
$request
->
set
(
'format'
,
$format
);
$request
->
set
(
'type'
,
'delete'
);
$request
->
set
(
'model'
,
$this
->
getModel
());
$request
->
set
(
'identifier'
,
$this
->
identifier
());
$response
=
$request
->
execute
();
}
public
function
getModel
()
{
return
$this
->
_model
;
...
...
lib/Doctrine/Resource/Server.php
View file @
eca4f7a1
...
...
@@ -48,26 +48,19 @@ class Doctrine_Resource_Server extends Doctrine_Resource
{
$model
=
$request
->
get
(
'model'
);
$data
=
$request
->
get
(
'data'
);
$identifier
=
$request
->
get
(
'identifier'
);
$table
=
Doctrine_Manager
::
getInstance
()
->
getTable
(
$model
);
$identifier
=
$table
->
getIdentifier
();
if
(
!
is_array
(
$identifier
))
{
$identifier
=
array
(
$identifier
);
}
$existing
=
true
;
$pks
=
array
();
foreach
(
$identifier
as
$name
)
{
if
(
isset
(
$data
[
$name
])
&&
$data
[
$name
])
{
$pks
[
$name
]
=
$data
[
$name
];
}
else
{
foreach
(
$identifier
as
$key
=>
$value
)
{
if
(
!
$value
)
{
$existing
=
false
;
}
}
if
(
$existing
)
{
$record
=
$table
->
find
(
$
pks
);
$record
=
$table
->
find
(
$
identifier
);
}
else
{
$record
=
new
$model
();
}
...
...
@@ -78,6 +71,18 @@ class Doctrine_Resource_Server extends Doctrine_Resource
return
$record
->
toArray
(
true
,
true
);
}
public
function
executeDelete
(
$request
)
{
$model
=
$request
->
get
(
'model'
);
$identifier
=
$request
->
get
(
'identifier'
);
$table
=
Doctrine_Manager
::
getInstance
()
->
getTable
(
$model
);
$record
=
$table
->
find
(
$identifier
);
$record
->
delete
();
}
public
function
executeQuery
(
$request
)
{
$dql
=
$request
->
get
(
'dql'
);
...
...
playground/index.php
View file @
eca4f7a1
...
...
@@ -19,7 +19,10 @@ if ($action == 'server') {
$client
=
Doctrine_Resource_Client
::
getInstance
(
$config
);
$user
=
new
User
();
$user
=
$client
->
find
(
'User'
,
4
);
$user
->
Phonenumber
->
add
()
->
phonenumber
=
'555-5555'
;
$user
->
name
=
'jonnwage'
;
$user
->
save
();
print_r
(
$user
->
toArray
());
}
\ No newline at end of file
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