Commit 3ab8a56e authored by zYne's avatar zYne

--no commit message

--no commit message
parent badc58d7
...@@ -222,14 +222,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -222,14 +222,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
} }
switch (count($this->primaryKeys)) { switch (count($this->primaryKeys)) {
case 0: case 0:
$this->columns = array_merge(array('id' => $definition = array('id' =>
array('integer', new Doctrine_Column(
20, array('type' => 'integer',
array('autoincrement' => true, 'length' => 20,
'primary' => true 'autoincrement' => true,
) 'primary' => true,
) )));
), $this->columns); $this->columns = array_merge($definition, $this->columns);
$this->primaryKeys[] = 'id'; $this->primaryKeys[] = 'id';
$this->identifier = 'id'; $this->identifier = 'id';
...@@ -243,7 +243,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -243,7 +243,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
} else { } else {
foreach ($this->primaryKeys as $pk) { foreach ($this->primaryKeys as $pk) {
$e = $this->columns[$pk][2]; $e = $this->columns[$pk];
$found = false; $found = false;
...@@ -336,9 +336,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -336,9 +336,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$primary = array(); $primary = array();
foreach ($this->columns as $name => $column) { foreach ($this->columns as $name => $column) {
$definition = $column[2]; $definition = $column->getDefinition();
$definition['type'] = $column[0];
$definition['length'] = $column[1];
switch ($definition['type']) { switch ($definition['type']) {
case 'enum': case 'enum':
...@@ -517,7 +515,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -517,7 +515,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
throw new Doctrine_Table_Exception('Invalid argument given for column length'); throw new Doctrine_Table_Exception('Invalid argument given for column length');
} }
$this->columns[$name] = array($type, $length, $options); $definition = array('type' => $type, 'length' => $length) + $options;
$this->columns[$name] = new Doctrine_Column($definition);
if (isset($options['primary'])) { if (isset($options['primary'])) {
$this->primaryKeys[] = $name; $this->primaryKeys[] = $name;
...@@ -536,25 +535,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -536,25 +535,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{ {
return $this->hasDefaultValues; return $this->hasDefaultValues;
} }
/**
* getDefaultValueOf
* returns the default value(if any) for given column
*
* @param string $column
* @return mixed
*/
public function getDefaultValueOf($column)
{
$column = strtolower($column);
if ( ! isset($this->columns[$column])) {
throw new Doctrine_Table_Exception("Couldn't get default value. Column ".$column." doesn't exist.");
}
if (isset($this->columns[$column][2]['default'])) {
return $this->columns[$column][2]['default'];
} else {
return null;
}
}
/** /**
* @return mixed * @return mixed
*/ */
...@@ -1109,8 +1089,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1109,8 +1089,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
*/ */
final public function getEnumValues($field) final public function getEnumValues($field)
{ {
if (isset($this->columns[$field][2]['values'])) { if (isset($this->columns[$field]['values'])) {
return $this->columns[$field][2]['values']; return $this->columns[$field]['values'];
} else { } else {
return array(); return array();
} }
...@@ -1127,7 +1107,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1127,7 +1107,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if ($index instanceof Doctrine_Null) if ($index instanceof Doctrine_Null)
return $index; return $index;
return isset($this->columns[$field][2]['values'][$index]) ? $this->columns[$field][2]['values'][$index] : $index; return isset($this->columns[$field]['values'][$index]) ? $this->columns[$field]['values'][$index] : $index;
} }
/** /**
* enumIndex * enumIndex
...@@ -1186,35 +1166,34 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1186,35 +1166,34 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return $value; return $value;
} }
/** /**
* getDefinitionOf * getColumnCount
* *
* @return string ValueWrapper class name on success, false on failure * @return integer the number of columns in this table
*/ */
public function getValueWrapperOf($column) public function getColumnCount()
{ {
if (isset($this->columns[$column][2]['wrapper'])) { return $this->columnCount;
return $this->columns[$column][2]['wrapper'];
}
return false;
} }
/** /**
* getColumnCount * getColumn
* *
* @return integer the number of columns in this table * @param string $name
* @return Doctrine_Column
*/ */
final public function getColumnCount() public function getColumn($name)
{ {
return $this->columnCount; if (isset($this->columns[$name])) {
return $this->columns[$name];
}
throw new Doctrine_Table_Exception('Unknown column ' . $name);
} }
/** /**
* returns all columns and their definitions * returns all columns and their definitions
* *
* @return array * @return array
*/ */
final public function getColumns() public function getColumns()
{ {
return $this->columns; return $this->columns;
} }
...@@ -1227,31 +1206,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1227,31 +1206,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{ {
return array_keys($this->columns); return array_keys($this->columns);
} }
/**
* getDefinitionOf
*
* @return mixed array on success, false on failure
*/
public function getDefinitionOf($column)
{
if (isset($this->columns[$column])) {
return $this->columns[$column];
}
return false;
}
/**
* getTypeOf
*
* @return mixed string on success, false on failure
*/
public function getTypeOf($column)
{
if (isset($this->columns[$column])) {
return $this->columns[$column][0];
}
return false;
}
/** /**
* setData * setData
* doctrine uses this function internally * doctrine uses this function internally
...@@ -1321,6 +1275,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1321,6 +1275,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
{ {
return $this->options['tableName']; return $this->options['tableName'];
} }
public function setTableName($name)
{
$this->options['tableName'] = $name;
}
/** /**
* determine if table acts as tree * determine if table acts as tree
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment