cvs: pear /MDB2_Schema/MDB2 Schema.php
| From: | Lukas Smith | Date: | Mon, 01 May 2006 10:47:39 +0000 |
| Subject: | cvs: pear /MDB2_Schema/MDB2 Schema.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-39929@lists.php.net to get a copy of this message | ||
lsmith Mon May 1 10:47:39 2006 UTC
Modified files:
/pear/MDB2_Schema/MDB2 Schema.php
Log:
- automatically generate <on> tags in <sequence> tags if there is a table with the
same name and a single column primary key
http://cvs.php.net/viewcvs.cgi/pear/MDB2_Schema/MDB2/Schema.php?r1=1.68&r2=1.69&diff_format=u
Index: pear/MDB2_Schema/MDB2/Schema.php
diff -u pear/MDB2_Schema/MDB2/Schema.php:1.68 pear/MDB2_Schema/MDB2/Schema.php:1.69
--- pear/MDB2_Schema/MDB2/Schema.php:1.68 Thu Apr 13 15:27:21 2006
+++ pear/MDB2_Schema/MDB2/Schema.php Mon May 1 10:47:39 2006
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@pooteeweet.org> |
// +----------------------------------------------------------------------+
//
-// $Id: Schema.php,v 1.68 2006/04/13 15:27:21 lsmith Exp $
+// $Id: Schema.php,v 1.69 2006/05/01 10:47:39 lsmith Exp $
//
require_once 'MDB2.php';
@@ -472,11 +472,12 @@
$index_definitions[$index_name] = $definition;
}
}
- $constraints = $this->db->manager->listTableConstraints($table_name);
+ $constraints = $this->db->manager->listTableConstraints($table_name);
if (PEAR::isError($constraints)) {
return $constraints;
}
+
if (is_array($constraints) && !empty($constraints)
&& !array_key_exists('indexes', $table_definition)
) {
@@ -510,6 +511,21 @@
if (PEAR::isError($definition)) {
return $definition;
}
+ if (isset($database_definition['tables'][$sequence_name])
+ &&
isset($database_definition['tables'][$sequence_name]['indexes'])
+ ) {
+ foreach
($database_definition['tables'][$sequence_name]['indexes'] as $index) {
+ if (isset($index['primary']) &&
$index['primary']
+ && count($index['fields'] == 1)
+ ) {
+ $definition['on'] = array(
+ 'table' => $sequence_name,
+ 'field' => key($index['fields']),
+ );
+ break;
+ }
+ }
+ }
$database_definition['sequences'][$sequence_name] = $definition;
}
}