]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
orm fixes
authorAndrey Kutejko <andy128k@gmail.com>
Mon, 1 Sep 2014 16:14:59 +0000 (19:14 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Mon, 1 Sep 2014 16:14:59 +0000 (19:14 +0300)
ipf/legacy_orm/orm/export.php
ipf/legacy_orm/orm/template/owned.php

index 4a5ad4fc81475f070490cd7037a1e90df789dab7..a0cae9448c0043bbe046aafd1fc5af3c9d599c08 100644 (file)
@@ -426,8 +426,7 @@ class IPF_ORM_Export extends IPF_ORM_Connection_Module
             }
         }
 
-        $options['foreignKeys'] = isset($table->_options['foreignKeys']) ?
-                $table->_options['foreignKeys'] : array();
+        $options['foreignKeys'] = $table->getOption('foreignKeys', array());
 
         if ($table->getAttribute(IPF_ORM::ATTR_EXPORT) & IPF_ORM::EXPORT_CONSTRAINTS) {
             $constraints = array();
index 9d1822be7fbbdea6602943f8d9a20cc2ad67e01e..8134201d7152a61cf6b2132a85ef88e9a9b15d32 100644 (file)
@@ -32,12 +32,17 @@ class IPF_ORM_Template_Owned extends IPF_ORM_Template
             'exclude'   => $this->exclude,
             'verbose'   => $this->verbose,
         ));
-        $table->hasOne('User', $this->name, array(
-            'local'     => $this->columnName,
-            'exclude'   => $this->exclude,
-            'foreign'   => 'id',
-            'onDelete'  => 'CASCADE',
-        ));
+
+        $fks = $table->getOption('foreignKeys', array());
+        $fks[] = array(
+            'local'        => $this->columnName,
+            'foreign'      => 'id',
+            'foreignTable' => 'auth_users',
+            'onUpdate'     => null,
+            'onDelete'     => 'CASCADE',
+        );
+        $table->setOption('foreignKeys', $fks);
+
         $table->listeners['Owned_'.$this->columnName] = new IPF_ORM_Template_Listener_Owned($this->columnName);
     }
 }