1
0
mirror of synced 2025-01-29 19:41:45 +03:00

- s/numeric/decimal

This commit is contained in:
lsmith 2007-05-11 19:23:18 +00:00
parent ad0f389870
commit 34fd97312f
2 changed files with 11 additions and 12 deletions

View File

@ -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>

View File

@ -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.