| [ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: ColumnInfo.php,v 1.13 2005/02/25 15:47:02 pachanga Exp $ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://creole.phpdb.org>. 21 */ 22 23 /** 24 * Represents a Column. 25 * 26 * @author Hans Lellelid <hans@xmpl.org> 27 * @version $Revision: 1.13 $ 28 * @package creole.metadata 29 */ 30 class ColumnInfo { 31 32 // FIXME 33 // - Currently all member attributes are public. This should be fixed 34 // when PHP's magic __sleep() and __wakeup() functions & serialization support 35 // handles protected/private members. (if ever) 36 37 /** Column name */ 38 public $name; 39 40 /** Column Creole type. */ 41 public $type; 42 43 /** Column native type */ 44 public $nativeType; 45 46 /** Column length */ 47 public $size; 48 49 /** Column presision */ 50 public $precision; 51 52 /** Column scale (number of digits after decimal ) */ 53 public $scale; 54 55 /** Is nullable? */ 56 public $isNullable; 57 58 /** Default value */ 59 public $defaultValue; 60 61 /** Is autoincrement? */ 62 public $isAutoIncrement; 63 64 /** Table */ 65 public $table; 66 67 /** 68 * Additional and optional vendor specific information. 69 * @var vendorSpecificInfo 70 */ 71 protected $vendorSpecificInfo = array(); 72 73 /** 74 * Construct a new ColumnInfo object. 75 * 76 * @param TableInfo $table The table that owns this column. 77 * @param string $name Column name. 78 * @param int $type Creole type. 79 * @param string $nativeType Native type name. 80 * @param int $size Column length. 81 * @param int $scale Column scale (number of digits after decimal). 82 * @param boolean $is_nullable Whether col is nullable. 83 * @param mixed $default Default value. 84 * @param boolean $is_auto_increment Whether col is of autoIncrement type. 85 */ 86 function __construct(TableInfo 87 $table, 88 $name, 89 $type = null, 90 $nativeType = null, 91 $size = null, 92 $precision=null, 93 $scale = null, 94 $is_nullable = null, 95 $default = null, 96 $is_auto_increment = null, 97 $vendorInfo = array()) 98 { 99 $this->table = $table; 100 $this->name = $name; 101 $this->type = $type; 102 $this->nativeType = $nativeType; 103 $this->size = $size; 104 $this->precision = $precision; 105 $this->scale = $scale; 106 $this->isNullable = $is_nullable; 107 $this->defaultValue = $default; 108 $this->isAutoIncrement = $is_auto_increment; 109 $this->vendorSpecificInfo = $vendorInfo; 110 } 111 112 /** 113 * This "magic" method is invoked upon serialize(). 114 * Because the Info class hierarchy is recursive, we must handle 115 * the serialization and unserialization of this object. 116 * @return array The class variables that should be serialized (all must be public!). 117 */ 118 function __sleep() 119 { 120 return array('name', 'type', 'nativeType', 'size', 'precision', 'isNullable', 'defaultValue'); 121 } 122 123 /** 124 * Get column name. 125 * @return string 126 */ 127 public function getName() 128 { 129 return $this->name; 130 } 131 132 /** 133 * Get column type. 134 * @return int 135 */ 136 public function getType() 137 { 138 return $this->type; 139 } 140 141 /** 142 * Gets the native type name. 143 * @return string 144 */ 145 public function getNativeType() 146 { 147 return $this->nativeType; 148 } 149 150 /** 151 * Get column size. 152 * @return int 153 */ 154 public function getSize() 155 { 156 return $this->size; 157 } 158 159 /** 160 * Get column precision. 161 * @return int 162 */ 163 public function getPrecision() 164 { 165 return $this->precision; 166 } 167 168 /** 169 * Get column scale. 170 * Scale refers to number of digits after the decimal. Sometimes this is referred 171 * to as precision, but precision is the total number of digits (i.e. length). 172 * @return int 173 */ 174 public function getScale() 175 { 176 return $this->scale; 177 } 178 179 /** 180 * Get the default value. 181 * @return mixed 182 */ 183 public function getDefaultValue() 184 { 185 return $this->defaultValue; 186 } 187 188 /** 189 * Is column nullable? 190 * @return boolean 191 */ 192 public function isNullable() 193 { 194 return $this->isNullable; 195 } 196 197 /** 198 * Is column of autoincrement type? 199 * @return boolean 200 */ 201 public function isAutoIncrement() 202 { 203 return $this->isAutoIncrement === true; 204 } 205 206 /** 207 * Get vendor specific optional information for this column. 208 * @return array vendorSpecificInfo[] 209 */ 210 public function getVendorSpecificInfo() 211 { 212 return $this->vendorSpecificInfo; 213 } 214 215 /** 216 * @return string 217 */ 218 public function toString() 219 { 220 return $this->name; 221 } 222 223 /** 224 * Get parent table. 225 * @return TableInfo 226 */ 227 public function getTable() 228 { 229 return $this->table; 230 } 231 232 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |