1
0
mirror of synced 2025-01-06 00:57:10 +03:00

Schema classes updated

This commit is contained in:
zYne 2006-09-26 12:30:47 +00:00
parent 79cbc45510
commit 5cb3086d80
3 changed files with 48 additions and 103 deletions

View File

@ -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
public function isNotNull() { public function isNotNull() {
return $this->definition['notnull']; return $this->definition['notnull'];
} }
} // end of Doctrine_Schema_Column }

View File

@ -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(); return new ArrayIterator($this->definition);
} }
}
} // end of Doctrine_Schema_Object

View File

@ -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,32 +77,6 @@ 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
* @access public
*/
public function __toString( ) {
} // end of member function __toString
/**
*
* @return
* @access public
*/
public function __clone( ) {
} // end of member function __clone
/** /**
* *
* @return bool * @return bool
@ -118,20 +84,35 @@ class Doctrine_Schema_Table extends Doctrine_Schema_Object
*/ */
public function isValid( ) { public function isValid( ) {
} // end of member function isValid }
/**
* returns an array of Doctrine_Schema_Column objects
*
* @return array
*/
public function getColumns() {
return $this->children;
}
/**
* @return Doctrine_Schema_Column|false
*/
public function getColumn($name) {
if( ! isset($this->children[$name]))
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;
return $this;
}
}
} // end of Doctrine_Schema_Table