Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 final class DBSchema extends QueryIdentification
00016 {
00017 private $tables = array();
00018 private $order = array();
00019
00020 public function getTables()
00021 {
00022 return $this->tables;
00023 }
00024
00025 public function getTableNames()
00026 {
00027 return $this->order;
00028 }
00029
00034 public function addTable(DBTable $table)
00035 {
00036 $name = $table->getName();
00037
00038 Assert::isFalse(
00039 isset($this->tables[$name]),
00040 "table '{$name}' already exist"
00041 );
00042
00043 $this->tables[$table->getName()] = $table;
00044 $this->order[] = $name;
00045
00046 return $this;
00047 }
00048
00053 public function getTableByName($name)
00054 {
00055 if (!isset($this->tables[$name]))
00056 throw new MissingElementException(
00057 "table '{$name}' does not exist"
00058 );
00059
00060 return $this->tables[$name];
00061 }
00062
00063 public function toDialectString(Dialect $dialect)
00064 {
00065 $out = array();
00066
00067 foreach ($this->order as $name) {
00068 $out[] = $this->tables[$name]->toDialectString($dialect);
00069 }
00070
00071 return implode("\n\n", $out);
00072 }
00073 }
00074 ?>