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
a8fb6cde
Commit
a8fb6cde
authored
May 11, 2007
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- typo fixes
parent
16a2370e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
Object relational mapping - Relations - Foreign key associations - One-to-Many, Many-to-One.php
...- Foreign key associations - One-to-Many, Many-to-One.php
+1
-1
Object relational mapping - Relations - Foreign key associations - One-to-One.php
...g - Relations - Foreign key associations - One-to-One.php
+4
-4
Object relational mapping - Relations - Foreign key constraints - Constraint actions.php
...ations - Foreign key constraints - Constraint actions.php
+7
-7
No files found.
manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-Many, Many-to-One.php
View file @
a8fb6cde
...
...
@@ -4,7 +4,7 @@ class User extends Doctrine_Record {
public function setUp() {
$this->ownsMany('Phonenumber','Phonenumber.user_id');
}
public function setTableDefition() {
public function setTableDefi
ni
tion() {
$this->hasColumn('name','string',50);
$this->hasColumn('loginname','string',20);
$this->hasColumn('password','string',16);
...
...
manual/docs/Object relational mapping - Relations - Foreign key associations - One-to-One.php
View file @
a8fb6cde
...
...
@@ -4,7 +4,7 @@ The relationship between user and address is one-to-one aggregate.
The
Email
component
here
is
mapped
to
User
component
's column email_id hence their relation is called LOCALKEY relation.
The
Email
component
here
is
mapped
to
User
component
's column email_id hence their relation is called LOCALKEY relation.
On the other hand the Address component is mapped to User by it'
s
user_id
column
hence
the
relation
between
User
and
Address
is
called
FOREIGNKEY
relation
.
...
...
@@ -15,7 +15,7 @@ class User extends Doctrine_Record {
$this
->
ownsOne
(
'Email'
,
'User.email_id'
);
$this
->
ownsMany
(
'Phonenumber'
,
'Phonenumber.user_id'
);
}
public
function
setTableDefition
()
{
public
function
setTableDefi
ni
tion
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
50
);
$this
->
hasColumn
(
'loginname'
,
'string'
,
20
);
$this
->
hasColumn
(
'password'
,
'string'
,
16
);
...
...
@@ -29,10 +29,10 @@ class Email extends Doctrine_Record {
$this
->
hasColumn
(
'address'
,
'string'
,
150
);
}
}
class
Address
extends
Doctrine_Record
{
class
Address
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'street'
,
'string'
,
50
);
$this
->
hasColumn
(
'user_id'
,
'integer'
);
}
}
}
</
code
>
manual/docs/Object relational mapping - Relations - Foreign key constraints - Constraint actions.php
View file @
a8fb6cde
...
...
@@ -4,10 +4,10 @@ Delete or update the row from the parent table and automatically delete or updat
//SET NULL// :
Delete
or
update
the
row
from
the
parent
table
and
set
the
foreign
key
column
or
columns
in
the
child
table
to
NULL
.
This
is
valid
only
if
the
foreign
key
columns
do
not
have
the
NOT
NULL
qualifier
specified
.
Both
ON
DELETE
SET
NULL
and
ON
UPDATE
SET
NULL
clauses
are
supported
.
//NO ACTION// :
//NO ACTION// :
In
standard
SQL
,
NO
ACTION
means
no
action
in
the
sense
that
an
attempt
to
delete
or
update
a
primary
key
value
is
not
allowed
to
proceed
if
there
is
a
related
foreign
key
value
in
the
referenced
table
.
//RESTRICT// :
//RESTRICT// :
Rejects
the
delete
or
update
operation
for
the
parent
table
.
NO
ACTION
and
RESTRICT
are
the
same
as
omitting
the
ON
DELETE
or
ON
UPDATE
clause
.
//SET DEFAULT// :
...
...
@@ -15,22 +15,22 @@ Rejects the delete or update operation for the parent table. NO ACTION and RESTR
In
the
following
example
we
define
two
classes
,
User
and
Phonenumber
with
their
relation
being
one
-
to
-
many
.
We
also
add
a
foreign
key
constraint
with
onDelete
cascade
action
.
<
code
type
=
'php'
>
class
User
extends
Doctrine_Record
class
User
extends
Doctrine_Record
{
public
function
setUp
()
public
function
setUp
()
{
$this
->
hasMany
(
'Phonenumber'
,
'Phonenumber.user_id'
,
array
(
'onDelete'
=>
'cascade'
));
}
public
function
setTableDefi
tion
()
public
function
setTableDefi
nition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
50
);
$this
->
hasColumn
(
'loginname'
,
'string'
,
20
);
$this
->
hasColumn
(
'password'
,
'string'
,
16
);
}
}
class
Phonenumber
extends
Doctrine_Record
class
Phonenumber
extends
Doctrine_Record
{
public
function
setTableDefinition
()
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'phonenumber'
,
'string'
,
50
);
$this
->
hasColumn
(
'user_id'
,
'integer'
);
...
...
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