/** * @param \Classes\Db\DbTable|\Classes\Db\Constrant $table * * @return mixed */ public function createClassNamespace($table) { $arrNames = $this->getBaseNamespace(); if (isset($this->arrConfig['folder-database']) && $this->arrConfig['folder-database']) { $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); } if (isset($this->arrConfig['folder-name']) && $this->arrConfig['folder-name']) { $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); } if ($table->hasSchema()) { $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); } else { $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); } return implode(static::SEPARETOR, array_filter($arrNames)); }
/** * @param $constraint_name * @param $table_name * @param $column_name * * @return $this */ public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) { $objConstrantDependence = Constrant::getInstance()->populate(array('constrant' => $constraint_name, 'schema' => $schema, 'table' => $table_name, 'column' => $column_name, 'database' => $database)); $this->addDependece($objConstrantDependence); return $this; }
/** * @param array $constrant * @param string $table_name * @param int $schema */ private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) { if ($this->hasTable($table_name, $schema)) { $table = $this->getTable($table_name, $schema); if ($table->hasColumn($constrant["column_name"])) { $objConstrant = Constrant::getInstance()->populate(array('constrant' => $constrant['constraint_name'], 'schema' => $constrant['foreign_schema'], 'table' => $constrant['foreign_table'], 'column' => $constrant['foreign_column'], 'database' => $this->database)); switch ($constrant['constraint_type']) { case "FOREIGN KEY": $table->getColumn($constrant["column_name"])->addRefFk($objConstrant); break; case "PRIMARY KEY": $table->getColumn($constrant["column_name"])->setPrimaryKey($objConstrant)->setSequence($this->getSequence($table_name, $constrant["column_name"], $schema)); break; } } } }