From 1a14aa301d974bb08e95f75673bb35cc103e9f30 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 13 Jun 2007 21:37:33 +0000 Subject: [PATCH] MDB2 porting continues --- lib/Doctrine/Export/Pgsql.php | 6 ++--- lib/Doctrine/Export/Sqlite.php | 47 +++++++++++++++++++++++++++++++--- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/Export/Pgsql.php b/lib/Doctrine/Export/Pgsql.php index 88d31c5c9..1403331c6 100644 --- a/lib/Doctrine/Export/Pgsql.php +++ b/lib/Doctrine/Export/Pgsql.php @@ -70,13 +70,13 @@ class Doctrine_Export_Pgsql extends Doctrine_Export { $query = ''; if (isset($definition['match'])) { - $query .= ' MATCH '.$definition['match']; + $query .= ' MATCH ' . $definition['match']; } if (isset($definition['onUpdate'])) { - $query .= ' ON UPDATE '.$definition['on_update']; + $query .= ' ON UPDATE ' . $definition['on_update']; } if (isset($definition['onDelete'])) { - $query .= ' ON DELETE '.$definition['on_delete']; + $query .= ' ON DELETE ' . $definition['on_delete']; } if (isset($definition['deferrable'])) { $query .= ' DEFERRABLE'; diff --git a/lib/Doctrine/Export/Sqlite.php b/lib/Doctrine/Export/Sqlite.php index 0d1994934..5778da787 100644 --- a/lib/Doctrine/Export/Sqlite.php +++ b/lib/Doctrine/Export/Sqlite.php @@ -213,14 +213,53 @@ class Doctrine_Export_Sqlite extends Doctrine_Export throw $e; } } + /** + * getAdvancedForeignKeyOptions + * Return the FOREIGN KEY query section dealing with non-standard options + * as MATCH, INITIALLY DEFERRED, ON UPDATE, ... + * + * @param array $definition foreign key definition + * @return string + * @access protected + */ + public function getAdvancedForeignKeyOptions(array $definition) + { + $query = ''; + if (isset($definition['match'])) { + $query .= ' MATCH ' . $definition['match']; + } + if (isset($definition['onUpdate'])) { + $query .= ' ON UPDATE ' . $definition['on_update']; + } + if (isset($definition['onDelete'])) { + $query .= ' ON DELETE ' . $definition['on_delete']; + } + if (isset($definition['deferrable'])) { + $query .= ' DEFERRABLE'; + } else { + $query .= ' NOT DEFERRABLE'; + } + if (isset($definition['feferred'])) { + $query .= ' INITIALLY DEFERRED'; + } else { + $query .= ' INITIALLY IMMEDIATE'; + } + return $query; + } /** * create sequence * * @param string $seqName name of the sequence to be created * @param string $start start value of the sequence; default is 1 + * @param array $options An associative array of table options: + * array( + * 'comment' => 'Foo', + * 'charset' => 'utf8', + * 'collate' => 'utf8_unicode_ci', + * ); * @return boolean */ - public function createSequence($seqName, $start = 1) + public function createSequence($seqName, $start = 1, array $options = array()) { $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seqName), true); $seqcolName = $this->conn->quoteIdentifier($this->conn->getAttribute(Doctrine::ATTR_SEQCOL_NAME), true); @@ -248,12 +287,12 @@ class Doctrine_Export_Sqlite extends Doctrine_Export /** * drop existing sequence * - * @param string $seq_name name of the sequence to be dropped + * @param string $sequenceName name of the sequence to be dropped * @return boolean */ - public function dropSequence($seq_name) + public function dropSequence($sequenceName) { - $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($seq_name), true); + $sequenceName = $this->conn->quoteIdentifier($this->conn->getSequenceName($sequenceName), true); return $this->conn->exec('DROP TABLE ' . $sequenceName); } }