cvs: pear /Gtk_MDB_Designer/Designer Column.php Database.php

From: Date: Sun, 23 Mar 2003 04:41:57 +0000
Subject: cvs: pear /Gtk_MDB_Designer/Designer Column.php Database.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-9574@lists.php.net to get a copy of this message
alan_k Sat Mar 22 23:41:57 2003 EDT Modified files: /pear/Gtk_MDB_Designer/Designer Column.php Database.php Log: fix single inheritance and name overlaps Index: pear/Gtk_MDB_Designer/Designer/Column.php diff -u pear/Gtk_MDB_Designer/Designer/Column.php:1.5 pear/Gtk_MDB_Designer/Designer/Column.php:1.6 --- pear/Gtk_MDB_Designer/Designer/Column.php:1.5 Sat Mar 22 23:29:25 2003 +++ pear/Gtk_MDB_Designer/Designer/Column.php Sat Mar 22 23:41:57 2003 @@ -16,7 +16,7 @@ // | Authors: Alan Knowles <alan@akbkhome.com> | // +----------------------------------------------------------------------+ // -// $Id: Column.php,v 1.5 2003/03/23 04:29:25 alan_k Exp $ +// $Id: Column.php,v 1.6 2003/03/23 04:41:57 alan_k Exp $ // // The column dataobject // @@ -92,7 +92,7 @@ break; case 'pgsql': case 'oci8': // no idea if this works.. - $r .= " DEFAULT nextval('{$this->table->name}_{$this->name}_sequence') "; + $r .= " DEFAULT nextval('{$this->table->name}__{$this->name}_sequence') "; } } return $r; @@ -121,9 +121,9 @@ case 'fbsql': return; case 'pgsql': - return "CREATE SEQUENCE {$this->table->name}_{$this->name}_sequence INCREMENT 1 START 1"; + return "CREATE SEQUENCE {$this->table->name}__{$this->name}_sequence INCREMENT 1 START 1"; case 'oci8': - return "CREATE SEQUENCE {$this->table->name}_{$this->name}_sequence START WITH 1 INCREMENT BY 1"; + return "CREATE SEQUENCE {$this->table->name}__{$this->name}_sequence START WITH 1 INCREMENT BY 1"; } } /** @@ -152,7 +152,7 @@ return "ALTER TABLE {$this->table->name} ADD {$index} {$this->name}_index ({$this->name})"; case 'pgsql': case 'oci8': - return "CREATE {$unique} INDEX {$this->table->name}_{$this->name}_index on {$this->table->name} ({$this->name})"; + return "CREATE {$unique} INDEX {$this->table->name}__{$this->name}_index on {$this->table->name} ({$this->name})"; } } Index: pear/Gtk_MDB_Designer/Designer/Database.php diff -u pear/Gtk_MDB_Designer/Designer/Database.php:1.2 pear/Gtk_MDB_Designer/Designer/Database.php:1.3 --- pear/Gtk_MDB_Designer/Designer/Database.php:1.2 Sat Mar 22 10:40:56 2003 +++ pear/Gtk_MDB_Designer/Designer/Database.php Sat Mar 22 23:41:57 2003 @@ -16,7 +16,7 @@ // | Authors: Alan Knowles <alan@akbkhome.com> | // +----------------------------------------------------------------------+ // -// $Id: Database.php,v 1.2 2003/03/22 15:40:56 alan_k Exp $ +// $Id: Database.php,v 1.3 2003/03/23 04:41:57 alan_k Exp $ // // The Core text routines for database data interation // @@ -112,13 +112,38 @@ $db = MDB::factory($dbtype); //echo "loaded factory?"; //print_r($db); + + + $ret = ''; - foreach($this->tables as $table) { + // attempt to handle inheritance.. = really needs recursive coding. + $done = array(); + foreach($this->tables as $key => $table) { + if (isset($done[$key])) { + continue; + } + if ($table->inherits) { + $keyB = $this->findTableByName($table->inherits); + if (!isset($done[$keyB])) { + $ret .= $this->tables[$keyB]->toSQL($db); + } + $done[$keyB] = true; + } $ret .= $table->toSQL($db); + $done[$key]= true; } return $ret; } + + function findTableByName($name) { + foreach($this->tables as $k=>$table) { + if ($table->name == $name) { + return $k; + } + } + } + /** * save to SQL (not mdb).. *

« previous php.pear.cvs (#9574) next »