1 |
<?php
|
2 |
/*
|
3 |
* $Id: Table.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
|
4 |
*
|
5 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
6 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
7 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
8 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
9 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
10 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
11 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
12 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
13 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
14 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
15 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16 |
*
|
17 |
* This software consists of voluntary contributions made by many individuals
|
18 |
* and is licensed under the LGPL. For more information, see
|
19 |
* <http://www.phpdoctrine.com>.
|
20 |
*/
|
21 |
Doctrine::autoload('Doctrine_Schema_Object');
|
22 |
/**
|
23 |
* class Doctrine_Schema_Table
|
24 |
* Holds information on a database table
|
25 |
*
|
26 |
* @package Doctrine
|
27 |
* @subpackage Schema
|
28 |
* @link www.phpdoctrine.com
|
29 |
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
|
30 |
* @since 1.0
|
31 |
* @version $Revision: 2702 $
|
32 |
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
|
33 |
* @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
|
34 |
*/
|
35 |
class Doctrine_Schema_Table extends Doctrine_Schema_Object implements Countable, IteratorAggregate
|
36 |
{
|
37 |
|
38 |
protected $definition = array('name' => '',
|
39 |
'check' => '',
|
40 |
'charset' => '',
|
41 |
'description' => '');
|
42 |
/**
|
43 |
* Relations this table has with others. An array of Doctrine_Schema_Relation
|
44 |
*/
|
45 |
private $relations = array();
|
46 |
/**
|
47 |
*
|
48 |
* @return bool
|
49 |
* @access public
|
50 |
*/
|
51 |
public function isValid( )
|
52 |
{
|
53 |
|
54 |
}
|
55 |
/**
|
56 |
* returns an array of Doctrine_Schema_Column objects
|
57 |
*
|
58 |
* @return array
|
59 |
*/
|
60 |
public function getColumns()
|
61 |
{
|
62 |
return $this->children;
|
63 |
}
|
64 |
/**
|
65 |
* @return Doctrine_Schema_Column|false
|
66 |
*/
|
67 |
public function getColumn($name)
|
68 |
{
|
69 |
if ( ! isset($this->children[$name])) {
|
70 |
return false;
|
71 |
}
|
72 |
return $this->children[$name];
|
73 |
}
|
74 |
/**
|
75 |
*
|
76 |
* @param Doctrine_Schema_Column column
|
77 |
* @return Doctrine_Schema_Table
|
78 |
* @access public
|
79 |
*/
|
80 |
public function addColumn(Doctrine_Schema_Column $column)
|
81 |
{
|
82 |
$name = $column->get('name');
|
83 |
$this->children[$name] = $column;
|
84 |
|
85 |
return $this;
|
86 |
}
|
87 |
|
88 |
/**
|
89 |
* Adds a relation between a local column and a 2nd table / column
|
90 |
*
|
91 |
* @param Doctrine_Schema_Relation Relation
|
92 |
*
|
93 |
*/
|
94 |
public function setRelation(Doctrine_Schema_Relation $relation) {
|
95 |
$this->relations[] = $relation;
|
96 |
}
|
97 |
/**
|
98 |
* Return all the relations this table has with others
|
99 |
*
|
100 |
* @return array Array of Doctrine_Schema_Relation
|
101 |
*/
|
102 |
public function getRelations() {
|
103 |
return $this->relations;
|
104 |
}
|
105 |
|
106 |
}
|