From: Andrey Kutejko Date: Mon, 1 Sep 2014 16:14:59 +0000 (+0300) Subject: orm fixes X-Git-Tag: 0.6~17 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=b6530a16f601c8cb42c4c2458402cc3487f1d806;p=ipf-legacy-orm.git orm fixes --- diff --git a/ipf/legacy_orm/orm/export.php b/ipf/legacy_orm/orm/export.php index 4a5ad4f..a0cae94 100644 --- a/ipf/legacy_orm/orm/export.php +++ b/ipf/legacy_orm/orm/export.php @@ -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(); diff --git a/ipf/legacy_orm/orm/template/owned.php b/ipf/legacy_orm/orm/template/owned.php index 9d1822b..8134201 100644 --- a/ipf/legacy_orm/orm/template/owned.php +++ b/ipf/legacy_orm/orm/template/owned.php @@ -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); } }