From b6530a16f601c8cb42c4c2458402cc3487f1d806 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 1 Sep 2014 19:14:59 +0300 Subject: [PATCH] orm fixes --- ipf/legacy_orm/orm/export.php | 3 +-- ipf/legacy_orm/orm/template/owned.php | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) 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); } } -- 2.49.0