changes to support setting the tableName and properly create enum column values
This commit is contained in:
parent
9c32fef9bf
commit
2f7d4cbca1
@ -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 .'\');');
|
||||
|
||||
$content = sprintf(self::$tpl, $options['className'],
|
||||
$opt = isset($options['tableName']) && !empty($options['tableName']) ? str_repeat(' ', 8) . '$this->setTableName(\''. $options['tableName'].'\');':'';
|
||||
|
||||
$content = sprintf(self::$tpl, $options['className'],$opt,
|
||||
$this->buildColumnDefinition($columns),
|
||||
$this->buildRelationDefinition($relations));
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user