- s/numeric/decimal
This commit is contained in:
parent
ad0f389870
commit
34fd97312f
@ -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>
|
||||
|
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user