src/Propel/Model/Database.php
public function addTable($data)
	{
		if ($data instanceof Table) {
			$tbl = $data; // alias
			$tbl->setDatabase($this);
			if ($tbl->getSchema() === null) $tbl->setSchema($this->getSchema());
			if (isset($this->tablesByName[$tbl->getName()])) {
				return;
//				throw new EngineException("Duplicate table declared: " . $tbl->getName());
			}
			$this->tableList[] = $tbl;
			$this->tablesByName[$tbl->getName()] = $tbl;
			$this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl;
			$this->tablesByPhpName[ $tbl->getPhpName() ] = $tbl;
			if (strpos($tbl->getNamespace(), '\\') === 0) {
				$tbl->setNamespace(substr($tbl->getNamespace(), 1));
			} elseif ($namespace = $this->getNamespace()) {
				if ($tbl->getNamespace() === null) {
					$tbl->setNamespace($namespace);
				} else {
					$tbl->setNamespace($namespace . '\\' . $tbl->getNamespace());
				}
			}
			if ($tbl->getPackage() === null) {
				$tbl->setPackage($this->getPackage());
			}
			return $tbl;
		} else {
			$tbl = new Table();
			$tbl->setDatabase($this);
			$tbl->setSchema($this->getSchema());
			$tbl->loadFromXML($data);
			return $this->addTable($tbl); // call self w/ different param
		}
	}
public function addTable($data)
	{
		if ($data instanceof Table) {
			$tbl = $data; // alias
			$tbl->setDatabase($this);
			if ($tbl->getSchema() === null) $tbl->setSchema($this->getSchema());
			if (isset($this->tablesByName[$tbl->getName()])) {
				return;
//				throw new EngineException("Duplicate table declared: " . $tbl->getName());
			}
			$this->tableList[] = $tbl;
			$this->tablesByName[$tbl->getName()] = $tbl;
			$this->tablesByLowercaseName[strtolower($tbl->getName())] = $tbl;
			$this->tablesByPhpName[ $tbl->getPhpName() ] = $tbl;
			if (strpos($tbl->getNamespace(), '\\') === 0) {
				$tbl->setNamespace(substr($tbl->getNamespace(), 1));
			} elseif ($namespace = $this->getNamespace()) {
				if ($tbl->getNamespace() === null) {
					$tbl->setNamespace($namespace);
				} else {
					$tbl->setNamespace($namespace . '\\' . $tbl->getNamespace());
				}
			}
			if ($tbl->getPackage() === null) {
				$tbl->setPackage($this->getPackage());
			}
			return $tbl;
		} else {
			$tbl = new Table();
			$tbl->setDatabase($this);
			$tbl->setSchema($this->getSchema());
			$tbl->loadFromXML($data);
			return $this->addTable($tbl); // call self w/ different param
		}
	}
public function addTable ( $ data ) { if ( $ data instanceof Table ) { $ tbl = $ data ; // alias $ tbl -> setDatabase ( $ this ) ; if ( $ tbl -> getSchema ( ) === null ) $ tbl -> setSchema ( $ this -> getSchema ( ) ) ; if ( isset ( $ this -> tablesByName [ $ tbl -> getName ( ) ] ) ) { return ; //				throw new EngineException("Duplicate table declared: " . $tbl->getName()); } $ this -> tableList [ ] = $ tbl ; $ this -> tablesByName [ $ tbl -> getName ( ) ] = $ tbl ; $ this -> tablesByLowercaseName [ strtolower ( $ tbl -> getName ( ) ) ] = $ tbl ; $ this -> tablesByPhpName [ $ tbl -> getPhpName ( ) ] = $ tbl ; if ( strpos ( $ tbl -> getNamespace ( ) , '\\' ) === 0 ) { $ tbl -> setNamespace ( substr ( $ tbl -> getNamespace ( ) , 1 ) ) ; } elseif ( $ namespace = $ this -> getNamespace ( ) ) { if ( $ tbl -> getNamespace ( ) === null ) { $ tbl -> setNamespace ( $ namespace ) ; } else { $ tbl -> setNamespace ( $ namespace . '\\' . $ tbl -> getNamespace ( ) ) ; } } if ( $ tbl -> getPackage ( ) === null ) { $ tbl -> setPackage ( $ this -> getPackage ( ) ) ; } return $ tbl ; } else { $ tbl = new Table ( ) ; $ tbl -> setDatabase ( $ this ) ; $ tbl -> setSchema ( $ this -> getSchema ( ) ) ; $ tbl -> loadFromXML ( $ data ) ; return $ this -> addTable ( $ tbl ) ; // call self w/ different param } }
An utility method to add a new table from an xml attribute.
An utility method to add a new table from an xml attribute .