Fix foreign key constraints.
authorIain Patterson <me@iain.cx>
Wed, 10 Apr 2013 16:41:41 +0000 (12:41 -0400)
committerIain Patterson <me@iain.cx>
Wed, 10 Apr 2013 16:41:41 +0000 (12:41 -0400)
OrderState references a contact ID rather than a user.
Foreign keys must be explicitly set as NULL from Propel.

lib/order.php
propel/schema.xml

index 74306d9..5c7e0d8 100644 (file)
     $hub_id = $_POST['hub_id'];
     $quantity = $_POST['quantity'];
     $driver_id = $_POST['driver_id'];
+    if (! $driver_id) $driver_id = null;
     $state = $_POST['state'];
     if (! $state) $state = $GLOBALS['STATE_PLACED'];
 
         return false;
       }
     }
+    else $hub_id = null;
 
     if (! is_numeric($quantity)) {
       echo "<p>Invalid quantity!</p>\n";
index b6a4804..62658f5 100644 (file)
       <reference local="order_id" foreign="id"/>
     </foreign-key>
     <foreign-key foreignTable="User" phpName="User" refPhpName="OrderState">
-      <reference local="user_id" foreign="id"/>
+      <reference local="user_id" foreign="contact_id"/>
     </foreign-key>
     <foreign-key foreignTable="Contact" phpName="Driver" refPhpName="OrderState">
       <reference local="driver_id" foreign="id"/>