1
0
mirror of synced 2025-01-18 06:21:40 +03:00
This commit is contained in:
zYne 2007-03-26 16:35:16 +00:00
parent a03d7c6cd5
commit 7157693d28

View File

@ -27,7 +27,11 @@ class Order extends Doctrine_Record
} }
public function setUp() public function setUp()
{ {
$this->hasOne('Product', 'Order.product_id', array('constraint' => true)); $this->hasOne('Product', 'Order.product_id');
// foreign key columns should *always* have indexes
$this->index('product_id', array('fields' => 'product_id'));
} }
} }
</code> </code>
@ -36,8 +40,9 @@ 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,
product_no integer REFERENCES products (id), product_id integer REFERENCES products (id),
quantity integer quantity integer,
INDEX product_id_idx (product_id)
) )
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.