From: Andrey Kutejko Date: Mon, 1 Sep 2014 16:14:59 +0000 (+0300) Subject: orm fixes X-Git-Tag: 0.6~153 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=57733284bd5610d2410fec8f13d2c00555ea12fd;p=ipf.git orm fixes --- diff --git a/ipf/admin/legacymodel.php b/ipf/admin/legacymodel.php index 5c98159..10c17c1 100644 --- a/ipf/admin/legacymodel.php +++ b/ipf/admin/legacymodel.php @@ -26,7 +26,7 @@ class IPF_Admin_Model extends IPF_Admin_Component return IPF_ORM::getTable($this->modelName); } - private function query($searchValue, $filters) + protected function query($searchValue, $filters) { if (method_exists($this->modelName, 'ordering')) { $m = new $this->modelName; 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); } }