/** * Creates an column node * * @param object $column The Creole column * @return object The column node instance */ protected function createColumnNode($column) { $node = $this->doc->createElement("column"); $table = $column->getTable(); $colName = $column->getName(); $colType = $column->getType(); $colSize = $column->getSize(); $colScale = $column->getScale(); if ($colType === CreoleTypes::OTHER) { $this->log("Column [" . $table->getName() . "." . $colName . "] has a column type (" . $column->getNativeType() . ") that Propel does not support.", PROJECT_MSG_WARN); } $node->setAttribute("name", $colName); if ($this->isSamePhpName()) { $node->setAttribute("phpName", $colName); } $node->setAttribute("type", PropelTypes::getPropelType($colType)); if ($colSize > 0 && ($colType == CreoleTypes::CHAR || $colType == CreoleTypes::VARCHAR || $colType == CreoleTypes::LONGVARCHAR || $colType == CreoleTypes::DECIMAL || $colType == CreoleTypes::FLOAT || $colType == CreoleTypes::NUMERIC)) { $node->setAttribute("size", (string) $colSize); } if ($colScale > 0 && ($colType == CreoleTypes::DECIMAL || $colType == CreoleTypes::FLOAT || $colType == CreoleTypes::NUMERIC)) { $node->setAttribute("scale", (string) $colScale); } if (!$column->isNullable()) { $node->setAttribute("required", "true"); } if ($column->isAutoIncrement()) { $node->setAttribute("autoIncrement", "true"); } if (in_array($colName, $this->getTablePkCols($table))) { $node->setAttribute("primaryKey", "true"); } if (($defValue = $column->getDefaultValue()) !== null) { $node->setAttribute("default", iconv($this->dbEncoding, 'utf-8', $defValue)); } if ($vendorNode = $this->createVendorInfoNode($column->getVendorSpecificInfo())) { $node->appendChild($vendorNode); } return $node; }
/** * Creates an column node * * @param object $column The Creole column * @return object The column node instance */ protected function createColumnNode($column) { $node = $this->doc->createElement("column"); $table = $column->getTable(); $colName = $column->getName(); $colType = $column->getType(); $colSize = $column->getSize(); $colScale = $column->getScale(); if ($colType === CreoleTypes::OTHER) { $this->log("Column [" . $table->getName() . "." . $colName . "] has a column type (".$column->getNativeType().") that Propel does not support.", PROJECT_MSG_WARN); } $node->setAttribute("name", $colName); if ($this->isSamePhpName()) { $node->setAttribute("phpName", $colName); } $node->setAttribute("type", PropelTypes::getPropelType($colType)); if ($colSize > 0 && ( $colType == CreoleTypes::CHAR || $colType == CreoleTypes::VARCHAR || $colType == CreoleTypes::LONGVARCHAR || $colType == CreoleTypes::DECIMAL || $colType == CreoleTypes::FLOAT || $colType == CreoleTypes::NUMERIC)) { $node->setAttribute("size", (string) $colSize); } if ($colScale > 0 && ( $colType == CreoleTypes::DECIMAL || $colType == CreoleTypes::FLOAT || $colType == CreoleTypes::NUMERIC)) { $node->setAttribute("scale", (string) $colScale); } if (!$column->isNullable()) { $node->setAttribute("required", "true"); } if ($column->isAutoIncrement()) { $node->setAttribute("autoIncrement", "true"); } if (in_array($colName, $this->getTablePkCols($table))) { $node->setAttribute("primaryKey", "true"); } //following changed to insert '' instead of blank if default is empty but not null. And to not insert CURRENT_TIMESTAMP since creole can't handle it. $defValue = $column->getDefaultValue(); if (null !== $defValue && 'CURRENT_TIMESTAMP' != $defValue) { if ('' === $defValue) { $node->setAttribute("default", "''"); } else { $node->setAttribute("default", iconv($this->dbEncoding, 'utf-8', $defValue)); } } if ($vendorNode = $this->createVendorInfoNode($column->getVendorSpecificInfo())) { $node->appendChild($vendorNode); } return $node; }