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
04bca791
Commit
04bca791
authored
Jun 24, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
2206476d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
36 deletions
+66
-36
classes.php
tests/classes.php
+66
-36
No files found.
tests/classes.php
View file @
04bca791
<?php
class
Entity
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
ownsOne
(
'Email'
,
'Entity.email_id'
);
$this
->
ownsMany
(
'Phonenumber'
,
'Phonenumber.entity_id'
);
$this
->
ownsOne
(
'Account'
,
'Account.entity_id'
);
class
Entity
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
ownsOne
(
'Email'
,
array
(
'local'
=>
'email_id'
));
$this
->
ownsMany
(
'Phonenumber'
,
array
(
'foreign'
=>
'entity_id'
));
$this
->
ownsOne
(
'Account'
,
array
(
'foreign'
=>
'entity_id'
));
$this
->
hasMany
(
'Entity'
,
array
(
'local'
=>
'entity1'
,
'refClass'
=>
'EntityReference'
,
'foreign'
=>
'entity2'
,
'equal'
=>
true
));
}
public
function
setTableDefinition
()
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
20
,
'autoincrement|primary'
);
$this
->
hasColumn
(
'name'
,
'string'
,
50
);
$this
->
hasColumn
(
'loginname'
,
'string'
,
20
,
array
(
'unique'
));
...
...
@@ -21,8 +24,10 @@ class Entity extends Doctrine_Record {
$this
->
option
(
'subclasses'
,
array
(
'User'
,
'Group'
));
}
}
class
FieldNameTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
FieldNameTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'someColumn'
,
'string'
,
200
,
array
(
'default'
=>
'some string'
));
$this
->
hasColumn
(
'someEnum'
,
'enum'
,
4
,
array
(
'default'
=>
'php'
,
'values'
=>
array
(
'php'
,
'java'
,
'python'
)));
$this
->
hasColumn
(
'someArray'
,
'array'
,
100
,
array
(
'default'
=>
array
()));
...
...
@@ -30,33 +35,43 @@ class FieldNameTest extends Doctrine_Record {
$this
->
hasColumn
(
'someInt'
,
'integer'
,
20
,
array
(
'default'
=>
11
));
}
}
class
EntityReference
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
EntityReference
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'entity1'
,
'integer'
,
null
,
'primary'
);
$this
->
hasColumn
(
'entity2'
,
'integer'
,
null
,
'primary'
);
//$this->setPrimaryKey(array('entity1', 'entity2'));
}
}
class
Account
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
Account
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'entity_id'
,
'integer'
);
$this
->
hasColumn
(
'amount'
,
'integer'
);
}
}
class
EntityAddress
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'user_id'
,
'integer'
);
$this
->
hasColumn
(
'address_id'
,
'integer'
);
class
EntityAddress
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'user_id'
,
'integer'
,
null
,
array
(
'primary'
=>
true
));
$this
->
hasColumn
(
'address_id'
,
'integer'
,
null
,
array
(
'primary'
=>
true
));
}
}
class
Address
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
hasMany
(
'User'
,
'Entityaddress.entity_id'
);
class
Address
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
hasMany
(
'User'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'address_id'
,
'refClass'
=>
'EntityAddress'
));
}
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'address'
,
'string'
,
200
);
$this
->
hasColumn
(
'address'
,
'string'
,
200
);
}
}
...
...
@@ -88,28 +103,35 @@ class Description extends Doctrine_Record {
}
}
class
UserTable
extends
Doctrine_Table
{
}
class
User
extends
Entity
{
public
function
setUp
()
{
class
User
extends
Entity
{
public
function
setUp
()
{
parent
::
setUp
();
$this
->
hasMany
(
'Address'
,
'Entityaddress.address_id'
);
$this
->
hasMany
(
'Address'
,
array
(
'local'
=>
'user_id'
,
'foreign'
=>
'address_id'
,
'refClass'
=>
'EntityAddress'
));
$this
->
ownsMany
(
'Album'
,
'Album.user_id'
);
$this
->
ownsMany
(
'Book'
,
'Book.user_id'
);
$this
->
hasMany
(
'Group'
,
'Groupuser.group_id'
);
$this
->
option
(
'inheritanceMap'
,
array
(
'type'
=>
0
));
}
/** Custom validation */
public
function
validate
()
{
public
function
validate
()
{
// Allow only one name!
if
(
$this
->
name
!==
'The Saint'
)
{
$this
->
errorStack
()
->
add
(
'name'
,
'notTheSaint'
);
}
}
public
function
validateOnInsert
()
{
public
function
validateOnInsert
()
{
if
(
$this
->
password
!==
'Top Secret'
)
{
$this
->
errorStack
()
->
add
(
'password'
,
'pwNotTopSecret'
);
}
}
public
function
validateOnUpdate
()
{
public
function
validateOnUpdate
()
{
if
(
$this
->
loginname
!==
'Nobody'
)
{
$this
->
errorStack
()
->
add
(
'loginname'
,
'notNobody'
);
}
...
...
@@ -117,7 +139,8 @@ class User extends Entity {
}
class
SelfRefTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
50
);
$this
->
hasColumn
(
'created_by'
,
'integer'
);
}
...
...
@@ -126,20 +149,25 @@ class SelfRefTest extends Doctrine_Record
$this
->
hasOne
(
'SelfRefTest as createdBy'
,
array
(
'local'
=>
'created_by'
));
}
}
class
Groupuser
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
Groupuser
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'added'
,
'integer'
);
$this
->
hasColumn
(
'group_id'
,
'integer'
);
$this
->
hasColumn
(
'user_id'
,
'integer'
);
}
}
class
Phonenumber
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
Phonenumber
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'phonenumber'
,
'string'
,
20
);
$this
->
hasColumn
(
'entity_id'
,
'integer'
);
}
public
function
setUp
()
{
$this
->
hasOne
(
'Entity'
,
'Phonenumber.entity_id'
);
public
function
setUp
()
{
$this
->
hasOne
(
'Entity'
,
array
(
'local'
=>
'entity_id'
));
}
}
...
...
@@ -153,9 +181,11 @@ class Element extends Doctrine_Record {
$this
->
hasOne
(
'Element as Parent'
,
'Element.parent_id'
);
}
}
class
Email
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'address'
,
'string'
,
150
,
'email|unique'
);
class
Email
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'address'
,
'string'
,
150
,
'email|unique'
);
}
}
class
Book
extends
Doctrine_Record
{
...
...
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