Commit 34fd9731 authored by lsmith's avatar lsmith

- s/numeric/decimal

parent ad0f3898
...@@ -8,7 +8,7 @@ Doctrine provides the following simple check operators: ...@@ -8,7 +8,7 @@ Doctrine provides the following simple check operators:
> less than constraint ( < ) > less than constraint ( < )
* '''gte''' * '''gte'''
> greater than or equal to constraint ( >= ) > greater than or equal to constraint ( >= )
* '''lte''' * '''lte'''
> less than or equal to constraint ( <= ) > less than or equal to constraint ( <= )
...@@ -19,8 +19,8 @@ class Product extends Doctrine_Record ...@@ -19,8 +19,8 @@ class Product extends Doctrine_Record
{ {
public function setTableDefinition() public function setTableDefinition()
{ {
$this->hasColumn('id', 'integer', 4, 'primary'); $this->hasColumn('id', 'integer', 4, 'primary');
$this->hasColumn('price', 'numeric', 200, array('gt' => 0); $this->hasColumn('price', 'decimal', 18, array('gt' => 0);
} }
} }
</code> </code>
......
...@@ -3,13 +3,13 @@ A foreign key constraint specifies that the values in a column (or a group of co ...@@ -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: Say you have the product table with the following definition:
<code type='php'> <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('id', 'integer', null, 'primary');
$this->hasColumn('name', 'string'); $this->hasColumn('name', 'string');
$this->hasColumn('price', 'numeric'); $this->hasColumn('price', 'decimal', 18);
} }
} }
</code> </code>
...@@ -19,7 +19,7 @@ Let's also assume you have a table storing orders of those products. We want to ...@@ -19,7 +19,7 @@ Let's also assume you have a table storing orders of those products. We want to
<code type='php'> <code type='php'>
class Order extends Doctrine_Record class Order extends Doctrine_Record
{ {
public function setTableDefinition() public function setTableDefinition()
{ {
$this->hasColumn('order_id', 'integer', null, 'primary'); $this->hasColumn('order_id', 'integer', null, 'primary');
$this->hasColumn('product_id', 'integer'); $this->hasColumn('product_id', 'integer');
...@@ -28,15 +28,15 @@ class Order extends Doctrine_Record ...@@ -28,15 +28,15 @@ class Order extends Doctrine_Record
public function setUp() public function setUp()
{ {
$this->hasOne('Product', 'Order.product_id'); $this->hasOne('Product', 'Order.product_id');
// foreign key columns should *always* have indexes // foreign key columns should *always* have indexes
$this->index('product_id', array('fields' => 'product_id')); $this->index('product_id', array('fields' => 'product_id'));
} }
} }
</code> </code>
When exported the class 'Order' would execute the following sql: When exported the class 'Order' would execute the following sql:
CREATE TABLE orders ( CREATE TABLE orders (
order_id integer PRIMARY KEY, order_id integer PRIMARY KEY,
...@@ -47,5 +47,4 @@ CREATE TABLE orders ( ...@@ -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. 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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment