Commit 5cb3086d authored by zYne's avatar zYne

Schema classes updated

parent 79cbc455
...@@ -38,14 +38,13 @@ class Doctrine_Schema_Column extends Doctrine_Schema_Object implements IteratorA ...@@ -38,14 +38,13 @@ class Doctrine_Schema_Column extends Doctrine_Schema_Object implements IteratorA
* column definitions * column definitions
* @var array $definition * @var array $definition
*/ */
private $definition = array('name' => '', protected $definition = array('name' => '',
'type' => '', 'type' => '',
'unique' => false, 'unique' => false,
'primary' => false, 'primary' => false,
'notnull' => false, 'notnull' => false,
'default' => null, 'default' => null,
); );
public function __construct(array $definition) { public function __construct(array $definition) {
foreach($this->definition as $key => $val) { foreach($this->definition as $key => $val) {
...@@ -71,5 +70,4 @@ class Doctrine_Schema_Column extends Doctrine_Schema_Object implements IteratorA ...@@ -71,5 +70,4 @@ class Doctrine_Schema_Column extends Doctrine_Schema_Object implements IteratorA
public function isNotNull() { public function isNotNull() {
return $this->definition['notnull']; return $this->definition['notnull'];
} }
} // end of Doctrine_Schema_Column }
...@@ -33,69 +33,35 @@ ...@@ -33,69 +33,35 @@
* class Doctrine_Schema_Object * class Doctrine_Schema_Object
* Catches any non-property call from child classes and throws an exception. * Catches any non-property call from child classes and throws an exception.
*/ */
abstract class Doctrine_Schema_Object abstract class Doctrine_Schema_Object implements IteratorAggregate, Countable {
implements IteratorAggregate, Countable
{
/** Aggregations: */
/** Compositions: */
/*** Attributes: ***/
/**
*
* @param string _property
* @param mixed _value
* @return
* @access public
*/
public function __set( $_property, $_value )
{
throw new Doctrine_Schema_Exception('Assignment of non-property');
} // end of member function __set
/**
*
* @param string _property
* @return
* @access public
*/
public function __get( $_property )
{
throw new Doctrine_Schema_Exception('Access of non-property');
} // end of member function __get
protected $children = array();
protected $definition = array();
/** /**
* *
* @return int * @return int
* @access public * @access public
*/ */
public function count( ) public function count() {
{ if( ! empty($this->childs))
if(!empty($this->childs))
{
return count($this->childs); return count($this->childs);
}
return 0; return count($this->definition);
} }
/** /**
* getIterator
* *
* @return * @return ArrayIterator
* @access public * @access public
*/ */
public function getIterator( ) public function getIterator() {
{ if( ! empty($this->childs))
if(!empty($this->childs))
{
return new ArrayIterator($this->childs); return new ArrayIterator($this->childs);
}
return new ArrayIterator();
}
} // end of Doctrine_Schema_Object return new ArrayIterator($this->definition);
}
}
...@@ -37,14 +37,6 @@ class Doctrine_Schema_Table extends Doctrine_Schema_Object ...@@ -37,14 +37,6 @@ class Doctrine_Schema_Table extends Doctrine_Schema_Object
implements Countable, Countable, IteratorAggregate implements Countable, Countable, IteratorAggregate
{ {
/** Aggregations: */
/** Compositions: */
var $m_Vector = array();
var $m_;
/*** Attributes: ***/
/** /**
* Unique key fields * Unique key fields
* @access public * @access public
...@@ -85,53 +77,42 @@ class Doctrine_Schema_Table extends Doctrine_Schema_Object ...@@ -85,53 +77,42 @@ class Doctrine_Schema_Table extends Doctrine_Schema_Object
* @access public * @access public
*/ */
public $description; public $description;
/**
* Columns of the table
* @access private
*/
private $childs;
/** /**
* *
* @return * @return bool
* @access public * @access public
*/ */
public function __toString( ) { public function isValid( ) {
} // end of member function __toString }
/** /**
* returns an array of Doctrine_Schema_Column objects
* *
* @return * @return array
* @access public
*/ */
public function __clone( ) { public function getColumns() {
return $this->children;
} // end of member function __clone }
/** /**
* * @return Doctrine_Schema_Column|false
* @return bool
* @access public
*/ */
public function isValid( ) { public function getColumn($name) {
if( ! isset($this->children[$name]))
} // end of member function isValid return false;
return $this->children[$name];
}
/** /**
* *
* @param Doctrine_Schema_Column column * @return Doctrine_Schema_Column * @param Doctrine_Schema_Column column
* @return Doctrine_Schema_Table
* @access public * @access public
*/ */
public function addColumn( $column = null ) { public function addColumn(Doctrine_Schema_Column $column) {
$name = $column->getName();
} // end of member function addColumn $this->children[$name] = $column;
} // end of Doctrine_Schema_Table return $this;
}
}
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