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
208fa1ee
Commit
208fa1ee
authored
Sep 21, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for saving models.
parent
9992cf30
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
14 deletions
+44
-14
Client.php
lib/Doctrine/Resource/Client.php
+7
-0
Collection.php
lib/Doctrine/Resource/Collection.php
+5
-0
Query.php
lib/Doctrine/Resource/Query.php
+2
-6
Record.php
lib/Doctrine/Resource/Record.php
+10
-0
Server.php
lib/Doctrine/Resource/Server.php
+20
-8
No files found.
lib/Doctrine/Resource/Client.php
View file @
208fa1ee
...
...
@@ -12,4 +12,11 @@ class Doctrine_Resource_Client extends Doctrine_Resource
{
return
new
Doctrine_Resource_Query
(
$this
->
config
);
}
public
function
newRecord
(
$model
)
{
$record
=
new
Doctrine_Resource_Record
(
$model
,
$this
->
config
);
return
$record
;
}
}
\ No newline at end of file
lib/Doctrine/Resource/Collection.php
View file @
208fa1ee
...
...
@@ -5,6 +5,11 @@ class Doctrine_Resource_Collection extends Doctrine_Access implements Countable,
public
$config
=
array
();
public
$model
=
null
;
public
function
__construct
(
$model
)
{
$this
->
model
=
$model
;
}
public
function
count
()
{
return
count
(
$data
);
...
...
lib/Doctrine/Resource/Query.php
View file @
208fa1ee
...
...
@@ -78,14 +78,10 @@ class Doctrine_Resource_Query extends Doctrine_Resource
{
$model
=
$passedKey
?
$passedKey
:
$this
->
getModel
();
$collection
=
new
Doctrine_Resource_Collection
();
$collection
->
model
=
$model
;
$collection
->
config
=
$this
->
config
;
$collection
=
new
Doctrine_Resource_Collection
(
$model
,
$this
->
config
);
foreach
(
$array
as
$record
)
{
$r
=
new
Doctrine_Resource_Record
();
$r
->
config
=
$this
->
config
;
$r
->
model
=
$model
;
$r
=
new
Doctrine_Resource_Record
(
$model
,
$this
->
config
);
foreach
(
$record
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
...
...
lib/Doctrine/Resource/Record.php
View file @
208fa1ee
...
...
@@ -6,6 +6,12 @@ class Doctrine_Resource_Record extends Doctrine_Record_Abstract implements Count
public
$model
=
null
;
public
$changes
=
array
();
public
function
__construct
(
$model
,
$config
)
{
$this
->
model
=
$model
;
$this
->
config
=
$config
;
}
public
function
get
(
$get
)
{
if
(
!
isset
(
$this
->
data
[
$get
]))
{
...
...
@@ -46,6 +52,10 @@ class Doctrine_Resource_Record extends Doctrine_Record_Abstract implements Count
$response
=
Doctrine_Resource
::
request
(
$this
->
config
[
'url'
],
$request
);
$array
=
Doctrine_Parser
::
load
(
$response
,
$request
[
'format'
]);
$this
->
data
=
array_merge
(
$this
->
data
,
$array
);
return
$array
;
}
public
function
toArray
()
...
...
lib/Doctrine/Resource/Server.php
View file @
208fa1ee
...
...
@@ -27,25 +27,37 @@ class Doctrine_Resource_Server extends Doctrine_Resource
throw
new
Doctrine_Resource_Exception
(
'You must specify a dql query'
);
}
}
else
if
(
$request
[
'type'
]
==
'save'
)
{
$table
=
Doctrine_Manager
::
getInstance
()
->
getTable
(
$request
[
'model'
]);
$model
=
$request
[
'model'
];
$table
=
Doctrine_Manager
::
getInstance
()
->
getTable
(
$model
);
$pks
=
(
array
)
$table
->
getIdentifier
();
$pks
=
array_flip
(
$pks
);
$hasPk
=
false
;
foreach
(
array_keys
(
$pks
)
as
$key
)
{
$pks
[
$key
]
=
$request
[
'data'
][
$key
];
if
(
isset
(
$request
[
'data'
][
$key
])
&&
$request
[
'data'
][
$key
])
{
$pks
[
$key
]
=
$request
[
'data'
][
$key
];
$hasPk
=
true
;
}
}
$record
=
$table
->
find
(
$pks
);
$changes
=
$request
[
'changes'
];
if
(
$hasPk
)
{
$record
=
$table
->
find
(
$pks
);
}
else
{
$record
=
new
$model
();
}
foreach
(
$changes
as
$key
=>
$value
)
{
$record
->
$key
=
$value
;
if
(
isset
(
$request
[
'changes'
])
&&
!
empty
(
$request
[
'changes'
]))
{
$changes
=
$request
[
'changes'
];
foreach
(
$changes
as
$key
=>
$value
)
{
$record
->
$key
=
$value
;
}
}
$record
->
save
();
$result
=
array
(
'success'
=>
true
);
$result
=
$record
->
toArray
(
);
}
return
Doctrine_Parser
::
dump
(
$result
,
$format
);
...
...
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