diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index 4db3e70d4..0c80a0671 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -205,7 +205,7 @@ class Doctrine_Export extends Doctrine_Connection_Module * * @return string */ - public function createTableSql($name, array $fields, array $options = array()) + public function createTableSql($name, array $fields, array $options = array(), $exportForeignKeySql = true) { if ( ! $name) { throw new Doctrine_Export_Exception('no valid table name specified'); @@ -242,7 +242,7 @@ class Doctrine_Export extends Doctrine_Connection_Module $sql[] = $query; - if (isset($options['foreignKeys'])) { + if (isset($options['foreignKeys']) && $exportForeignKeySql) { foreach ((array) $options['foreignKeys'] as $k => $definition) { if (is_array($definition)) { @@ -1047,8 +1047,9 @@ class Doctrine_Export extends Doctrine_Connection_Module $record = new $name(); $table = $record->getTable(); $data = $table->getExportableFormat(); - - $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options']); + $exportForeignKeySql = is_bool($table->getOption('export_foreign_key_sql')) ? $table->getOption('export_foreign_key_sql'):true; + + $query = $this->conn->export->createTableSql($data['tableName'], $data['columns'], $data['options'], $exportForeignKeySql); if (is_array($query)) { $sql = array_merge($sql, $query); diff --git a/lib/Doctrine/Export/Mysql.php b/lib/Doctrine/Export/Mysql.php index cbee9ac4f..ea5ff6237 100644 --- a/lib/Doctrine/Export/Mysql.php +++ b/lib/Doctrine/Export/Mysql.php @@ -87,7 +87,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export * * @return void */ - public function createTableSql($name, array $fields, array $options = array()) + public function createTableSql($name, array $fields, array $options = array(), $exportForeignKeySql = true) { if ( ! $name) throw new Doctrine_Export_Exception('no valid table name specified'); @@ -169,7 +169,7 @@ class Doctrine_Export_Mysql extends Doctrine_Export } $sql[] = $query; - if (isset($options['foreignKeys'])) { + if (isset($options['foreignKeys']) && $exportForeignKeySql) { foreach ((array) $options['foreignKeys'] as $k => $definition) { if (is_array($definition)) { diff --git a/lib/Doctrine/Export/Pgsql.php b/lib/Doctrine/Export/Pgsql.php index befdae1e1..745474a78 100644 --- a/lib/Doctrine/Export/Pgsql.php +++ b/lib/Doctrine/Export/Pgsql.php @@ -291,7 +291,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export * @param array $options * @return unknown */ - public function createTableSql($name, array $fields, array $options = array()) + public function createTableSql($name, array $fields, array $options = array(), $exportForeignKeySql = true) { if ( ! $name) { throw new Doctrine_Export_Exception('no valid table name specified'); @@ -318,7 +318,7 @@ class Doctrine_Export_Pgsql extends Doctrine_Export } } - if (isset($options['foreignKeys'])) { + if (isset($options['foreignKeys']) && $exportForeignKeySql) { foreach ((array) $options['foreignKeys'] as $k => $definition) { if (is_array($definition)) { diff --git a/lib/Doctrine/Export/Sqlite.php b/lib/Doctrine/Export/Sqlite.php index dedeab085..c02c95b25 100644 --- a/lib/Doctrine/Export/Sqlite.php +++ b/lib/Doctrine/Export/Sqlite.php @@ -155,7 +155,7 @@ class Doctrine_Export_Sqlite extends Doctrine_Export * * @return void */ - public function createTableSql($name, array $fields, array $options = array()) + public function createTableSql($name, array $fields, array $options = array(), $exportForeignKeySql = true) { if ( ! $name) { throw new Doctrine_Export_Exception('no valid table name specified'); diff --git a/lib/Doctrine/Record/Abstract.php b/lib/Doctrine/Record/Abstract.php index a94ad4736..59b1232fa 100644 --- a/lib/Doctrine/Record/Abstract.php +++ b/lib/Doctrine/Record/Abstract.php @@ -148,7 +148,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access */ public function option($name, $value = null) { - if ($value == null) { + if ($value === null) { if (is_array($name)) { foreach ($name as $k => $v) { $this->_table->setOption($k, $v); @@ -270,7 +270,7 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access } else { $className = 'Doctrine_Template_' . $tpl; - if ( ! class_exists($className, true)) { + if ( ! class_exists($className, true)) { throw new Doctrine_Record_Exception("Couldn't load plugin."); } diff --git a/lib/Doctrine/Table.php b/lib/Doctrine/Table.php index 9f83eddf3..8dc336bbd 100644 --- a/lib/Doctrine/Table.php +++ b/lib/Doctrine/Table.php @@ -294,16 +294,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable } $this->repository = new Doctrine_Table_Repository($this); } - /** - * getTemplates - * returns all templates attached to this table - * - * @return array an array containing all templates - */ - public function getTemplates() - { - return $this->_templates; - } /** * export * exports this table to database based on column and option definitions