1
0
mirror of synced 2025-01-19 23:11:41 +03:00

changes to support setting the tableName and properly create enum column values

This commit is contained in:
gnat 2007-09-21 07:14:37 +00:00
parent 9c32fef9bf
commit 2f7d4cbca1
2 changed files with 8 additions and 5 deletions

View File

@ -94,6 +94,7 @@ class %s extends Doctrine_Record
{
public function setTableDefinition()
{
%s
%s
}
public function setUp()
@ -144,8 +145,8 @@ END;
if (isset($column['unsigned']) && $column['unsigned']) {
$a[] = '\'unsigned\' => true';
}
if ($column['type'] == 'enum' && isset($column['values']) && $column['values']) {
$a[] = '\'values\' => array(' . implode(',', $column['values']) . ')';
if ($column['type'] == 'enum' && isset($column['values']) ) {
$a[] = '\'values\' => array(\'' . implode('\',\'', $column['values']) . '\')';
}
if ( ! empty($a)) {
@ -228,9 +229,10 @@ END;
throw new Doctrine_Import_Builder_Exception('Missing class name.');
}
//$opt = array(0 => str_repeat(' ', 8) . '$this->setTableName(\''. $table .'\');');
$opt = isset($options['tableName']) && !empty($options['tableName']) ? str_repeat(' ', 8) . '$this->setTableName(\''. $options['tableName'].'\');':'';
$content = sprintf(self::$tpl, $options['className'],
$content = sprintf(self::$tpl, $options['className'],$opt,
$this->buildColumnDefinition($columns),
$this->buildRelationDefinition($relations));

View File

@ -73,7 +73,7 @@ class Doctrine_Import_Schema
$options = array();
$options['className'] = $properties['className'];
$options['fileName'] = $directory.DIRECTORY_SEPARATOR.$properties['className'].'.class.php';
$options['tableName'] = isset($properties['tableName'])?$properties['tableName']:null;
$columns = $properties['columns'];
$relations = isset($this->relations[$options['className']]) ? $this->relations[$options['className']]:array();
@ -116,6 +116,7 @@ class Doctrine_Import_Schema
$colDesc['default'] = isset($field['default']) ? (string) $field['default']:null;
$colDesc['notnull'] = isset($field['notnull']) ? (bool) (isset($field['notnull']) && $field['notnull']):null;
$colDesc['autoinc'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):null;
$colDesc['values'] = isset($field['values']) ? (array) $field['values']: null;
$columns[(string) $colDesc['name']] = $colDesc;
}