# Source for file Table.php

Documentation is available at Table.php

1. <?php
2. /*
3. * $Id: Table.php 1080 2007-02-10 18:17:08Z romanb $
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. * @package Doctrine
24. * @url http://www.phpdoctrine.com
25. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26. * @author Jukka Hassinen <Jukka.Hassinen@BrainAlliance.com>
27. * @version $Id: Table.php 1080 2007-02-10 18:17:08Z romanb $
28. */
29. /**
30. * class Doctrine_Schema_Table
31. * Holds information on a database table
32. * @package Doctrine
33. * @category Object Relational Mapping
34. * @link www.phpdoctrine.com
35. * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
36. * @since 1.0
37. * @version $Revision: 1080 $
38. * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
39. */
40. class Doctrine_Schema_Table extends Doctrine_Schema_Object implements Countable, IteratorAggregate
41. {
43. protected $definition = array('name' => '',
44. 'check' => '',
45. 'charset' => '',
46. 'description' => '');
47. /**
48. * Relations this table has with others. An array of Doctrine_Schema_Relation
49. */
50. private $relations = array();
51. /**
52. *
53. * @return bool
54. * @access public
55. */
56. public function isValid( )
57. {
59. }
60. /**
61. * returns an array of Doctrine_Schema_Column objects
62. *
63. * @return array
64. */
65. public function getColumns()
66. {
67. return $this->children;
68. }
69. /**
70. * @return Doctrine_Schema_Column|false
71. */
72. public function getColumn($name)
73. {
74. if ( ! isset($this->children[$name])) {
75. return false;
76. }
77. return $this->children[$name];
78. }
79. /**
80. *
81. * @param Doctrine_Schema_Column column
82. * @return Doctrine_Schema_Table
83. * @access public
84. */
85. public function addColumn(Doctrine_Schema_Column $column)
86. {
87. $name = $column->get('name');
88. $this->children[$name] = $column;
90. return $this;
91. }
93. /**
94. * Adds a relation between a local column and a 2nd table / column
95. *
96. * @param Doctrine_Schema_Relation Relation
97. *
98. */
99. public function setRelation(Doctrine_Schema_Relation $relation){
100. $this->relations[] = $relation;
101. }
102. /**
103. * Return all the relations this table has with others
104. *
105. * @return array Array of Doctrine_Schema_Relation
106. */
107. public function getRelations(){
108. return $this->relations;
109. }
111. }