cvs: pear /DB_DataObject/DataObject Generator.php
| From: | Alan Knowles | Date: | Tue, 24 Jun 2003 15:27:17 +0000 |
| Subject: | cvs: pear /DB_DataObject/DataObject Generator.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-11155@lists.php.net to get a copy of this message | ||
alan_k Tue Jun 24 11:27:17 2003 EDT
Modified files:
/pear/DB_DataObject/DataObject Generator.php
Log:
make unique a second class detector for primary key comparison.
Index: pear/DB_DataObject/DataObject/Generator.php
diff -u pear/DB_DataObject/DataObject/Generator.php:1.31
pear/DB_DataObject/DataObject/Generator.php:1.32
--- pear/DB_DataObject/DataObject/Generator.php:1.31 Thu Apr 17 08:05:05 2003
+++ pear/DB_DataObject/DataObject/Generator.php Tue Jun 24 11:27:17 2003
@@ -14,7 +14,7 @@
// +----------------------------------------------------------------------+
// | Author: Alan Knowles <alan@akbkhome.com>
// +----------------------------------------------------------------------+
-// $Id: Generator.php,v 1.31 2003/04/17 12:05:05 alan_k Exp $
+// $Id: Generator.php,v 1.32 2003/06/24 15:27:17 alan_k Exp $
/**
* Generation tools for DB_DataObject
@@ -220,6 +220,9 @@
$defs = $this->_definitions[$this->table];
$this->_newConfig .= "\n[{$this->table}]\n";
$keys_out = "\n[{$this->table}__keys]\n";
+ $keys_out_primary = '';
+ $keys_out_secondary = '';
+
foreach($defs as $t) {
$n=0;
@@ -276,18 +279,20 @@
continue;
}
$this->_newConfig .= "{$t->name} = $type\n";
- //$this->_newConfig->setValue("/{$this->table}",$t->name, $type);
// i've no idea if this will work well on other databases?
- // only use primary key, cause the setFrom blocks you setting all key items...
+ // only use primary key or nextval(), cause the setFrom blocks you setting all key
items...
+ // if no keys exist fall back to using unique
- if (preg_match("/(primary|unique|nextval\()/i",$t->flags)) {
- $keys_out .= "{$t->name} = $type\n";
-
//$this->_newConfig->setValue("/{$this->table}__keys",$t->name, $type);
+ if (preg_match("/(primary|nextval\()/i",$t->flags)) {
+ $keys_out_primary .= "{$t->name} = $type\n";
+ } else if (preg_match("/\sunique\s/i",$t->flags)) {
+ $keys_out_secondary .= "{$t->name} = $type\n";
}
}
- $this->_newConfig .= $keys_out;
+
+ $this->_newConfig .= $keys_out . (empty($keys_out_primary) ? $keys_out_secondary :
$keys_out_primary);
}