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
fad6255a
Commit
fad6255a
authored
Feb 27, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docs for CHECK constraints
parent
a336d424
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
Getting started - Exporting classes - Export options.php
.../Getting started - Exporting classes - Export options.php
+3
-0
Object relational mapping - Constraints and validators - Check.php
...lational mapping - Constraints and validators - Check.php
+41
-0
Object relational mapping - Constraints and validators - Introduction.php
...l mapping - Constraints and validators - Introduction.php
+7
-0
No files found.
manual/docs/Getting started - Exporting classes - Export options.php
View file @
fad6255a
...
...
@@ -8,4 +8,7 @@ $manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_ALL);
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_TABLES ^
Doctrine::EXPORT_CONSTRAINTS);
// turn off exporting
$manager->setAttribute(Doctrine::ATTR_EXPORT, Doctrine::EXPORT_NONE);
</code>
manual/docs/Object relational mapping - Constraints and validators - Check.php
0 → 100644
View file @
fad6255a
Doctrine
check
constraints
act
as
database
level
constraints
as
well
as
application
level
validators
.
When
a
record
with
check
validators
is
exported
additional
CHECK
constraints
are
being
added
to
CREATE
TABLE
statement
.
Doctrine
provides
the
following
simple
check
operators
:
*
'''gt'''
>
greater
than
constraint
(
>
)
*
'''lt'''
>
less
than
constraint
(
<
)
*
'''gte'''
>
greater
than
or
equal
to
constraint
(
>=
)
*
'''lte'''
>
less
than
or
equal
to
constraint
(
<=
)
Consider
the
following
example
:
<
code
type
=
'php'
>
class
Product
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
'primary'
);
$this
->
hasColumn
(
'price'
,
'numeric'
,
200
,
array
(
'gt'
=>
0
);
}
}
</
code
>
When
exported
the
given
class
definition
would
execute
the
following
statement
(
in
pgsql
)
:
CREATE
TABLE
product
(
id
INTEGER
,
price
NUMERIC
CHECK
(
price
>
0
)
PRIMARY
KEY
(
id
))
So
Doctrine
optionally
ensures
even
at
the
database
level
that
the
price
of
any
product
cannot
be
below
zero
.
>
NOTE
:
some
databases
don
'
t
support
CHECK
constraints
.
When
this
is
the
case
Doctrine
simple
skips
the
creation
of
check
constraints
.
If
the
Doctrine
validators
are
turned
on
the
given
definition
would
also
ensure
that
when
a
record
is
being
saved
its
price
is
always
greater
than
zero
.
If
some
of
the
prices
of
the
saved
products
within
a
transaction
is
below
zero
,
Doctrine
throws
Doctrine_Validator_Exception
and
automatically
rolls
back
the
transaction
.
manual/docs/Object relational mapping - Constraints and validators - Introduction.php
0 → 100644
View file @
fad6255a
Data
types
are
a
way
to
limit
the
kind
of
data
that
can
be
stored
in
a
table
.
For
many
applications
,
however
,
the
constraint
they
provide
is
too
coarse
.
For
example
,
a
column
containing
a
product
price
should
probably
only
accept
positive
values
.
But
there
is
no
standard
data
type
that
accepts
only
positive
numbers
.
Another
issue
is
that
you
might
want
to
constrain
column
data
with
respect
to
other
columns
or
rows
.
For
example
,
in
a
table
containing
product
information
,
there
should
be
only
one
row
for
each
product
number
.
[
source
:
http
://
www
.
postgresql
.
org
/
docs
/
8.2
/
static
/
ddl
-
constraints
.
html
#AEN2032]
Doctrine
allows
you
to
define
*
portable
*
constraints
on
columns
and
tables
.
Constraints
give
you
as
much
control
over
the
data
in
your
tables
as
you
wish
.
If
a
user
attempts
to
store
data
in
a
column
that
would
violate
a
constraint
,
an
error
is
raised
.
This
applies
even
if
the
value
came
from
the
default
value
definition
.
Doctrine
constraints
act
as
database
level
constraints
as
well
as
application
level
validators
.
This
means
double
security
:
the
database
doesn
'
t
allow
wrong
kind
of
values
and
neither
does
the
application
.
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