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
34fd9731
Commit
34fd9731
authored
May 11, 2007
by
lsmith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- s/numeric/decimal
parent
ad0f3898
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
12 deletions
+11
-12
Object relational mapping - Constraints and validators - Check.php
...lational mapping - Constraints and validators - Check.php
+3
-3
Object relational mapping - Relations - Foreign key constraints - Introduction.php
... - Relations - Foreign key constraints - Introduction.php
+8
-9
No files found.
manual/docs/Object relational mapping - Constraints and validators - Check.php
View file @
34fd9731
...
...
@@ -8,7 +8,7 @@ Doctrine provides the following simple check operators:
>
less
than
constraint
(
<
)
*
'''gte'''
>
greater
than
or
equal
to
constraint
(
>=
)
*
'''lte'''
*
'''lte'''
>
less
than
or
equal
to
constraint
(
<=
)
...
...
@@ -19,8 +19,8 @@ class Product extends Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
'primary'
);
$this
->
hasColumn
(
'price'
,
'
numeric'
,
200
,
array
(
'gt'
=>
0
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
'primary'
);
$this
->
hasColumn
(
'price'
,
'
decimal'
,
18
,
array
(
'gt'
=>
0
);
}
}
</
code
>
...
...
manual/docs/Object relational mapping - Relations - Foreign key constraints - Introduction.php
View file @
34fd9731
...
...
@@ -3,13 +3,13 @@ A foreign key constraint specifies that the values in a column (or a group of co
Say
you
have
the
product
table
with
the
following
definition
:
<
code
type
=
'php'
>
class
Product
extends
Doctrine_Record
class
Product
extends
Doctrine_Record
{
public
function
setTableDefinition
()
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
null
,
'primary'
);
$this
->
hasColumn
(
'name'
,
'string'
);
$this
->
hasColumn
(
'price'
,
'
numeric'
);
$this
->
hasColumn
(
'price'
,
'
decimal'
,
18
);
}
}
</
code
>
...
...
@@ -19,7 +19,7 @@ Let's also assume you have a table storing orders of those products. We want to
<code type='
php
'>
class Order extends Doctrine_Record
{
public function setTableDefinition()
public function setTableDefinition()
{
$this->hasColumn('
order_id
', '
integer
', null, '
primary
');
$this->hasColumn('
product_id
', '
integer
');
...
...
@@ -28,15 +28,15 @@ class Order extends Doctrine_Record
public function setUp()
{
$this->hasOne('
Product
', '
Order
.
product_id
');
// foreign key columns should *always* have indexes
$this->index('
product_id
', array('
fields
' => '
product_id
'));
}
}
</code>
When exported the class '
Order
'
would
execute
the
following
sql
:
When exported the class '
Order
'
would
execute
the
following
sql
:
CREATE
TABLE
orders
(
order_id
integer
PRIMARY
KEY
,
...
...
@@ -47,5 +47,4 @@ CREATE TABLE orders (
Now
it
is
impossible
to
create
orders
with
product_no
entries
that
do
not
appear
in
the
products
table
.
We
say
that
in
this
situation
the
orders
table
is
the
referencing
table
and
the
products
table
is
the
referenced
table
.
Similarly
,
there
are
referencing
and
referenced
columns
.
We
say
that
in
this
situation
the
orders
table
is
the
referencing
table
and
the
products
table
is
the
referenced
table
.
Similarly
,
there
are
referencing
and
referenced
columns
.
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