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
d4e34979
Commit
d4e34979
authored
Sep 25, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed some unwanted functions.
parent
1d3cdd0a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
151 additions
and
27 deletions
+151
-27
Client.php
lib/Doctrine/Resource/Client.php
+11
-17
Collection.php
lib/Doctrine/Resource/Collection.php
+3
-1
Record.php
lib/Doctrine/Resource/Record.php
+2
-2
Server.php
lib/Doctrine/Resource/Server.php
+13
-4
index.php
playground/index.php
+122
-3
No files found.
lib/Doctrine/Resource/Client.php
View file @
d4e34979
...
...
@@ -35,12 +35,12 @@ class Doctrine_Resource_Client extends Doctrine_Resource
{
public
$loadDoctrine
=
false
;
static
public
function
getInstance
(
$config
=
null
)
static
public
function
getInstance
(
$
url
=
null
,
$
config
=
null
)
{
static
$instance
;
if
(
!
$instance
)
{
$instance
=
new
Doctrine_Resource_Client
(
$config
);
$instance
=
new
Doctrine_Resource_Client
(
$
url
,
$
config
);
if
(
$instance
->
loadDoctrine
===
true
)
{
$instance
->
loadDoctrine
();
...
...
@@ -50,6 +50,15 @@ class Doctrine_Resource_Client extends Doctrine_Resource
return
$instance
;
}
public
function
__construct
(
$url
,
$config
)
{
if
(
$url
)
{
$config
[
'url'
]
=
$url
;
}
parent
::
__construct
(
$config
);
}
public
function
loadDoctrine
()
{
$path
=
'/tmp/'
.
md5
(
serialize
(
$this
->
getConfig
()));
...
...
@@ -92,19 +101,4 @@ class Doctrine_Resource_Client extends Doctrine_Resource
{
return
new
Doctrine_Resource_Table
(
$table
);
}
public
function
newQuery
()
{
return
new
Doctrine_Resource_Query
();
}
public
function
newRecord
(
$model
,
$loadRelations
=
true
)
{
return
new
Doctrine_Resource_Record
(
$model
,
$loadRelations
);
}
public
function
newCollection
(
$model
)
{
return
new
Doctrine_Resource_Collection
(
$model
);
}
}
\ No newline at end of file
lib/Doctrine/Resource/Collection.php
View file @
d4e34979
...
...
@@ -67,7 +67,9 @@ class Doctrine_Resource_Collection extends Doctrine_Resource_Access implements C
public
function
add
(
$value
=
null
)
{
if
(
!
$value
)
{
$value
=
Doctrine_Resource_Client
::
getInstance
()
->
newRecord
(
$this
->
_model
);
$model
=
$this
->
_model
;
$value
=
new
$model
();
}
$this
->
_data
[]
=
$value
;
...
...
lib/Doctrine/Resource/Record.php
View file @
d4e34979
...
...
@@ -71,9 +71,9 @@ class Doctrine_Resource_Record extends Doctrine_Resource_Access implements Count
foreach
(
$relations
as
$relation
)
{
if
(
$relation
[
'type'
]
===
Doctrine_Relation
::
ONE
)
{
$this
->
_data
[
$relation
[
'alias'
]]
=
Doctrine_Resource_Client
::
getInstance
()
->
newRecord
(
$relation
[
'class'
],
false
);
$this
->
_data
[
$relation
[
'alias'
]]
=
new
$relation
[
'class'
](
false
);
}
else
{
$this
->
_data
[
$relation
[
'alias'
]]
=
Doctrine_Resource_Client
::
getInstance
()
->
new
Collection
(
$relation
[
'class'
]);
$this
->
_data
[
$relation
[
'alias'
]]
=
new
Doctrine_Resource_
Collection
(
$relation
[
'class'
]);
}
}
}
...
...
lib/Doctrine/Resource/Server.php
View file @
d4e34979
...
...
@@ -32,18 +32,27 @@
* @since 1.0
*/
class
Doctrine_Resource_Server
extends
Doctrine_Resource
{
static
public
function
getInstance
(
$config
=
null
)
{
public
function
__construct
(
$name
=
null
,
$config
=
null
)
{
if
(
$name
)
{
$config
[
'name'
]
=
$name
;
}
parent
::
__construct
(
$config
);
}
static
public
function
getInstance
(
$name
,
$config
=
null
)
{
static
$instance
;
if
(
!
$instance
)
{
$instance
=
new
Doctrine_Resource_Server
(
$config
);
$instance
=
new
Doctrine_Resource_Server
(
$
name
,
$
config
);
}
return
$instance
;
}
public
function
executeSave
(
$request
)
{
$model
=
$request
->
get
(
'model'
);
...
...
playground/index.php
View file @
d4e34979
<?php
require_once
(
'playground.php'
);
require_once
(
'connection.php'
);
require_once
(
'models.php'
);
require_once
(
'data.php'
);
\ No newline at end of file
$action
=
isset
(
$_REQUEST
[
'action'
])
?
$_REQUEST
[
'action'
]
:
'client'
;
if
(
$action
==
'server'
)
{
require_once
(
'connection.php'
);
require_once
(
'models.php'
);
require_once
(
'data.php'
);
$name
=
'Doctrine_Resource_Playground'
;
$config
=
array
(
'models'
=>
$tables
);
$server
=
Doctrine_Resource_Server
::
getInstance
(
$name
,
$config
);
$server
->
run
(
$_REQUEST
);
}
else
{
$url
=
'http://localhost/~jwage/doctrine_trunk/playground/index.php?action=server'
;
$config
=
array
();
// Instantiate a new client
$client
=
Doctrine_Resource_Client
::
getInstance
(
$url
,
$config
);
// Retrieve a models table object
$table
=
$client
->
getTable
(
'User'
);
// Find record by identifier
$user
=
$table
->
find
(
4
);
// 2 ways to create queries
$query
=
new
Doctrine_Resource_Query
();
$query
->
from
(
'User u, u.Phonenumber p'
)
->
limit
(
2
);
// returns users
$users
=
$query
->
execute
();
print_r
(
$users
->
toArray
());
/*
Array
(
[User_0] => Array
(
[id] => 4
[name] => zYne
[loginname] =>
[password] =>
[type] => 0
[created] =>
[updated] =>
[email_id] => 1
[Phonenumber] => Array
(
[Phonenumber_0] => Array
(
[id] => 2
[phonenumber] => 123 123
[entity_id] => 4
)
)
)
[User_1] => Array
(
[id] => 5
[name] => Arnold Schwarzenegger
[loginname] =>
[password] =>
[type] => 0
[created] =>
[updated] =>
[email_id] => 2
[Phonenumber] => Array
(
[Phonenumber_0] => Array
(
[id] => 3
[phonenumber] => 123 123
[entity_id] => 5
)
[Phonenumber_1] => Array
(
[id] => 4
[phonenumber] => 456 456
[entity_id] => 5
)
[Phonenumber_2] => Array
(
[id] => 5
[phonenumber] => 789 789
[entity_id] => 5
)
)
)
)
*/
$user
=
new
User
();
$user
->
name
=
'Jonathan H. Wage'
;
$user
->
save
();
print_r
(
$user
->
toArray
());
/*
Array
(
[id] => 12
[name] => Jonathan H. Wage
[loginname] =>
[password] =>
[type] => 0
[created] =>
[updated] =>
[email_id] =>
)
*/
}
\ 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