[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 /* 3 * $Id: Column.php 351 2006-03-15 18:42:34Z hans $ 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 please see 19 * <http://propel.phpdb.org>. 20 */ 21 22 require_once 'propel/engine/database/model/XMLElement.php'; 23 include_once 'propel/engine/EngineException.php'; 24 include_once 'propel/engine/database/model/PropelTypes.php'; 25 include_once 'propel/engine/database/model/Inheritance.php'; 26 include_once 'propel/engine/database/model/Domain.php'; 27 28 /** 29 * A Class for holding data about a column used in an Application. 30 * 31 * @author Hans Lellelid <hans@xmpl.org> (Propel) 32 * @author Leon Messerschmidt <leon@opticode.co.za> (Torque) 33 * @author Jason van Zyl <jvanzyl@apache.org> (Torque) 34 * @author Jon S. Stevens <jon@latchkey.com> (Torque) 35 * @author Daniel Rall <dlr@finemaltcoding.com> (Torque) 36 * @author Byron Foster <byron_foster@yahoo.com> (Torque) 37 * @version $Revision: 351 $ 38 * @package propel.engine.database.model 39 */ 40 class Column extends XMLElement { 41 42 const DEFAULT_TYPE = "VARCHAR"; 43 44 private $name; 45 private $description; 46 private $phpName = null; 47 private $phpNamingMethod; 48 private $isNotNull = false; 49 private $size; 50 51 /** 52 * The name to use for the Peer constant that identifies this column. 53 * (Will be converted to all-uppercase in the templates.) 54 * @var string 55 */ 56 private $peerName; 57 58 /** 59 * Type as defined in schema.xml 60 * @var string 61 */ 62 private $propelType; 63 64 /** 65 * Type corresponding to Creole type 66 * @var int 67 */ 68 private $creoleType; 69 70 /** 71 * Native PHP type 72 * @var string "string", "boolean", "int", "double" 73 */ 74 private $phpType; 75 private $parentTable; 76 private $position; 77 private $isPrimaryKey = false; 78 private $isNodeKey = false; 79 private $nodeKeySep; 80 private $isUnique = false; 81 private $isAutoIncrement = false; 82 private $isLazyLoad = false; 83 private $defaultValue; 84 private $referrers; 85 // only one type is supported currently, which assumes the 86 // column either contains the classnames or a key to 87 // classnames specified in the schema. Others may be 88 // supported later. 89 private $inheritanceType; 90 private $isInheritance; 91 private $isEnumeratedClasses; 92 private $inheritanceList; 93 private $needsTransactionInPostgres; //maybe this can be retrieved from vendorSpecificInfo 94 95 /** class name to do input validation on this column */ 96 private $inputValidator = null; 97 98 private $domain; 99 100 /** 101 * Creates a new column and set the name 102 * 103 * @param name column name 104 */ 105 public function __construct($name = null) 106 { 107 $this->name = $name; 108 } 109 110 /** 111 * Return a comma delimited string listing the specified columns. 112 * 113 * @param columns Either a list of <code>Column</code> objects, or 114 * a list of <code>String</code> objects with column names. 115 * @deprecated Use the DDLBuilder->getColumnList() method instead; this will be removed in 1.3 116 */ 117 public static function makeList($columns, Platform $platform) 118 { 119 $list = array(); 120 foreach($columns as $col) { 121 if ($col instanceof Column) { 122 $col = $col->getName(); 123 } 124 $list[] = $platform->quoteIdentifier($col); 125 } 126 return implode(", ", $list); 127 } 128 129 /** 130 * Sets up the Column object based on the attributes that were passed to loadFromXML(). 131 * @see parent::loadFromXML() 132 */ 133 protected function setupObject() 134 { 135 try { 136 $dom = $this->getAttribute("domain"); 137 if ($dom) { 138 $this->domain = new Domain(); 139 $this->domain->copy($this->getTable()->getDatabase()->getDomain($dom)); 140 } else { 141 $this->domain = new Domain(); 142 $this->domain->copy($this->getPlatform()->getDomainForType(self::DEFAULT_TYPE)); 143 $this->setType(strtoupper($this->getAttribute("type"))); 144 } 145 146 //Name 147 $this->name = $this->getAttribute("name"); 148 149 $this->phpName = $this->getAttribute("phpName"); 150 $this->phpType = $this->getAttribute("phpType"); 151 $this->peerName = $this->getAttribute("peerName"); 152 153 if (empty($this->phpType)) { 154 $this->phpType = null; 155 } 156 157 // retrieves the method for converting from specified name to 158 // a PHP name. 159 $this->phpNamingMethod = $this->getAttribute("phpNamingMethod", $this->parentTable->getDatabase()->getDefaultPhpNamingMethod()); 160 161 $this->isPrimaryKey = $this->booleanValue($this->getAttribute("primaryKey")); 162 163 $this->isNodeKey = $this->booleanValue($this->getAttribute("nodeKey")); 164 $this->nodeKeySep = $this->getAttribute("nodeKeySep", "."); 165 166 $this->isNotNull = $this->booleanValue($this->getAttribute("required"), false); 167 168 // Regardless of above, if this column is a primary key then it can't be null. 169 if ($this->isPrimaryKey) { 170 $this->isNotNull = true; 171 } 172 173 //AutoIncrement/Sequences 174 $this->isAutoIncrement = $this->booleanValue($this->getAttribute("autoIncrement")); 175 $this->isLazyLoad = $this->booleanValue($this->getAttribute("lazyLoad")); 176 177 //Default column value. 178 $this->domain->replaceDefaultValue($this->getAttribute("default")); 179 $this->domain->replaceSize($this->getAttribute("size")); 180 $this->domain->replaceScale($this->getAttribute("scale")); 181 182 $this->inheritanceType = $this->getAttribute("inheritance"); 183 $this->isInheritance = ($this->inheritanceType !== null 184 && $this->inheritanceType !== "false"); // here we are only checking for 'false', so don't 185 // use boleanValue() 186 187 $this->inputValidator = $this->getAttribute("inputValidator"); 188 $this->description = $this->getAttribute("description"); 189 } catch (Exception $e) { 190 throw new EngineException("Error setting up column " . var_export($this->getAttribute("name"), true) . ": " . $e->getMessage()); 191 } 192 } 193 194 /** 195 * Gets domain for this column. 196 * @return Domain 197 */ 198 public function getDomain() 199 { 200 return $this->domain; 201 } 202 203 /** 204 * Returns table.column 205 */ 206 public function getFullyQualifiedName() 207 { 208 return ($this->parentTable->getName() . '.' . name); 209 } 210 211 /** 212 * Get the name of the column 213 */ 214 public function getName() 215 { 216 return $this->name; 217 } 218 219 /** 220 * Set the name of the column 221 */ 222 public function setName($newName) 223 { 224 $this->name = $newName; 225 } 226 227 /** 228 * Get the description for the Table 229 */ 230 public function getDescription() 231 { 232 return $this->description; 233 } 234 235 /** 236 * Set the description for the Table 237 * 238 * @param newDescription description for the Table 239 */ 240 public function setDescription($newDescription) 241 { 242 $this->description = $newDescription; 243 } 244 245 /** 246 * Get name to use in PHP sources 247 * @return string 248 */ 249 public function getPhpName() 250 { 251 if ($this->phpName === null) { 252 $inputs = array(); 253 $inputs[] = $this->name; 254 $inputs[] = $this->phpNamingMethod; 255 try { 256 $this->phpName = NameFactory::generateName(NameFactory::PHP_GENERATOR, $inputs); 257 } catch (EngineException $e) { 258 print $e->getMessage() . "\n"; 259 print $e->getTraceAsString(); 260 } 261 } 262 return $this->phpName; 263 } 264 265 /** 266 * Set name to use in PHP sources 267 */ 268 public function setPhpName($phpName) 269 { 270 $this->phpName = $phpName; 271 } 272 273 /** 274 * Get the Peer constant name that will identify this column. 275 * @return string 276 */ 277 public function getPeerName() { 278 return $this->peerName; 279 } 280 281 /** 282 * Set the Peer constant name that will identify this column. 283 * @param $name string 284 */ 285 public function setPeerName($name) { 286 $this->peerName = $name; 287 } 288 289 /** 290 * Get type to use in PHP sources. 291 * If no type has been specified, then uses results 292 * of getPhpNative(). 293 * 294 * The distinction between getPhpType() and getPhpNative() 295 * is not as salient in PHP as it is in Java, but we'd like to leave open the 296 * option of specifying complex types (objects) in the schema. While we can 297 * always cast to PHP native types, we can't cast objects (in PHP) -- hence the 298 * importance of maintaining this distinction. 299 * 300 * @return string The type name. 301 * @see getPhpNative() 302 */ 303 public function getPhpType() 304 { 305 if ($this->phpType !== null) { 306 return $this->phpType; 307 } 308 return $this->getPhpNative(); 309 } 310 311 /** 312 * Get the location of this column within the table (one-based). 313 * @return int value of position. 314 */ 315 public function getPosition() 316 { 317 return $this->position; 318 } 319 320 /** 321 * Get the location of this column within the table (one-based). 322 * @param int $v Value to assign to position. 323 */ 324 public function setPosition($v) 325 { 326 $this->position = $v; 327 } 328 329 /** 330 * Set the parent Table of the column 331 */ 332 public function setTable(Table $parent) 333 { 334 $this->parentTable = $parent; 335 } 336 337 /** 338 * Get the parent Table of the column 339 */ 340 public function getTable() 341 { 342 return $this->parentTable; 343 } 344 345 /** 346 * Returns the Name of the table the column is in 347 */ 348 public function getTableName() 349 { 350 return $this->parentTable->getName(); 351 } 352 353 /** 354 * Adds a new inheritance definition to the inheritance list and set the 355 * parent column of the inheritance to the current column 356 * @param mixed $inhdata Inheritance or XML data. 357 */ 358 public function addInheritance($inhdata) 359 { 360 if ($inhdata instanceof Inheritance) { 361 $inh = $inhdata; 362 $inh->setColumn($this); 363 if ($this->inheritanceList === null) { 364 $this->inheritanceList = array(); 365 $this->isEnumeratedClasses = true; 366 } 367 $this->inheritanceList[] = $inh; 368 return $inh; 369 } else { 370 $inh = new Inheritance(); 371 $inh->loadFromXML($inhdata); 372 return $this->addInheritance($inh); 373 } 374 } 375 376 /** 377 * Get the inheritance definitions. 378 */ 379 public function getChildren() 380 { 381 return $this->inheritanceList; 382 } 383 384 /** 385 * Determine if this column is a normal property or specifies a 386 * the classes that are represented in the table containing this column. 387 */ 388 public function isInheritance() 389 { 390 return $this->isInheritance; 391 } 392 393 /** 394 * Determine if possible classes have been enumerated in the xml file. 395 */ 396 public function isEnumeratedClasses() 397 { 398 return $this->isEnumeratedClasses; 399 } 400 401 /** 402 * Return the isNotNull property of the column 403 */ 404 public function isNotNull() 405 { 406 return $this->isNotNull; 407 } 408 409 /** 410 * Set the isNotNull property of the column 411 */ 412 public function setNotNull($status) 413 { 414 $this->isNotNull = (boolean) $status; 415 } 416 417 /** 418 * Return NOT NULL String for this column 419 * 420 * @return "NOT NULL" if null values are not allowed or an empty string. 421 */ 422 public function getNotNullString() 423 { 424 return $this->getTable()->getDatabase()->getPlatform()->getNullString($this->isNotNull()); 425 } 426 427 /** 428 * Set if the column is a primary key or not 429 */ 430 public function setPrimaryKey($pk) 431 { 432 $this->isPrimaryKey = (boolean) $pk; 433 } 434 435 /** 436 * Return true if the column is a primary key 437 */ 438 public function isPrimaryKey() 439 { 440 return $this->isPrimaryKey; 441 } 442 443 /** 444 * Set if the column is the node key of a tree 445 */ 446 public function setNodeKey($nk) 447 { 448 $this->isNodeKey = (boolean) $nk; 449 } 450 451 /** 452 * Return true if the column is a node key of a tree 453 */ 454 public function isNodeKey() 455 { 456 return $this->isNodeKey; 457 } 458 459 /** 460 * Set if the column is the node key of a tree 461 */ 462 public function setNodeKeySep($sep) 463 { 464 $this->nodeKeySep = (string) $sep; 465 } 466 467 /** 468 * Return true if the column is a node key of a tree 469 */ 470 public function getNodeKeySep() 471 { 472 return $this->nodeKeySep; 473 } 474 475 /** 476 * Set true if the column is UNIQUE 477 */ 478 public function setUnique($u) 479 { 480 $this->isUnique = $u; 481 } 482 483 /** 484 * Get the UNIQUE property 485 */ 486 public function isUnique() 487 { 488 return $this->isUnique; 489 } 490 491 /** 492 * Return true if the column requires a transaction in Postgres 493 */ 494 public function requiresTransactionInPostgres() 495 { 496 return $this->needsTransactionInPostgres; 497 } 498 499 /** 500 * Utility method to determine if this column is a foreign key. 501 */ 502 public function isForeignKey() 503 { 504 return ($this->getForeignKey() !== null); 505 } 506 507 /** 508 * Determine if this column is a foreign key that refers to the 509 * same table as another foreign key column in this table. 510 */ 511 public function isMultipleFK() 512 { 513 $fk = $this->getForeignKey(); 514 if ($fk !== null) { 515 $fks = $this->parentTable->getForeignKeys(); 516 for ($i=0, $len=count($fks); $i < $len; $i++) { 517 if ($fks[$i]->getForeignTableName() === $fk->getForeignTableName() 518 && !in_array($this->name, $fks[$i]->getLocalColumns()) ) { 519 return true; 520 } 521 } 522 } 523 524 // No multiple foreign keys. 525 return false; 526 } 527 528 /** 529 * get the foreign key object for this column 530 * if it is a foreign key or part of a foreign key 531 */ 532 public function getForeignKey() 533 { 534 return $this->parentTable->getForeignKey($this->name); 535 } 536 537 /** 538 * Utility method to get the related table of this column if it is a foreign 539 * key or part of a foreign key 540 */ 541 public function getRelatedTableName() 542 { 543 $fk = $this->getForeignKey(); 544 return ($fk === null ? null : $fk->getForeignTableName()); 545 } 546 547 548 /** 549 * Utility method to get the related column of this local column if this 550 * column is a foreign key or part of a foreign key. 551 */ 552 public function getRelatedColumnName() 553 { 554 $fk = $this->getForeignKey(); 555 if ($fk === null) { 556 return null; 557 } else { 558 $m = $fk->getLocalForeignMapping(); 559 $c = @$m[$this->name]; 560 if ($c === null) { 561 return null; 562 } else { 563 return $c; 564 } 565 } 566 } 567 568 /** 569 * Adds the foreign key from another table that refers to this column. 570 */ 571 public function addReferrer(ForeignKey $fk) 572 { 573 if ($this->referrers === null) { 574 $this->referrers = array(); 575 } 576 $this->referrers[] = $fk; 577 } 578 579 /** 580 * Get list of references to this column. 581 */ 582 public function getReferrers() 583 { 584 if ($this->referrers === null) { 585 $this->referrers = array(); 586 } 587 return $this->referrers; 588 } 589 590 /** 591 * Returns the colunm type 592 */ 593 public function setType($propelType) 594 { 595 $this->domain = new Domain(); 596 $this->domain->copy($this->getPlatform()->getDomainForType($propelType)); 597 598 $this->propelType = $propelType; 599 if ($propelType == PropelTypes::VARBINARY|| $propelType == PropelTypes::LONGVARBINARY || $propelType == PropelTypes::BLOB) { 600 $this->needsTransactionInPostgres = true; 601 } 602 } 603 604 /** 605 * Returns the column Creole type as a string. 606 * @return string The constant representing Creole type: e.g. "VARCHAR". 607 */ 608 public function getType() 609 { 610 return PropelTypes::getCreoleType($this->propelType); 611 } 612 613 /** 614 * Returns the column type as given in the schema as an object 615 */ 616 public function getPropelType() 617 { 618 return $this->propelType; 619 } 620 621 /** 622 * Utility method to know whether column needs Blob/Lob handling. 623 * @return boolean 624 */ 625 public function isLob() 626 { 627 return PropelTypes::isLobType($this->propelType); 628 } 629 630 /** 631 * Utility method to see if the column is a string 632 */ 633 public function isString() 634 { 635 return PropelTypes::isTextxType($this->propelType); 636 } 637 638 /** 639 * String representation of the column. This is an xml representation. 640 */ 641 public function toString() 642 { 643 $result = " <column name=\"" . $this->name . '"'; 644 if ($this->phpName !== null) { 645 $result .= " phpName=\"" . $this->phpName . '"'; 646 } 647 if ($this->isPrimaryKey) { 648 $result .= " primaryKey=\"" . ($this->isPrimaryKey ? "true" : "false"). '"'; 649 } 650 651 if ($this->isNotNull) { 652 $result .= " required=\"true\""; 653 } else { 654 $result .= " required=\"false\""; 655 } 656 657 $result .= " type=\"" . $this->propelType . '"'; 658 659 if ($this->domain->getSize() !== null) { 660 $result .= " size=\"" . $this->domain->getSize() . '"'; 661 } 662 663 if ($this->domain->getScale() !== null) { 664 $result .= " scale=\"" . $this->domain->getScale() . '"'; 665 } 666 667 if ($this->domain->getDefaultValue() !== null) { 668 $result .= " default=\"" . $this->domain->getDefaultValue() . '"'; 669 } 670 671 if ($this->isInheritance()) { 672 $result .= " inheritance=\"" . $this->inheritanceType 673 . '"'; 674 } 675 676 if ($this->isNodeKey()) { 677 $result .= " nodeKey=\"true\""; 678 if ($this->getNodeKeySep() !== null) { 679 $result .= " nodeKeySep=\"" . $this->nodeKeySep . '"'; 680 } 681 } 682 683 // Close the column. 684 $result .= " />\n"; 685 686 return $result; 687 } 688 689 /** 690 * Returns the size of the column 691 * @return string 692 */ 693 public function getSize() 694 { 695 return $this->domain->getSize(); 696 } 697 698 /** 699 * Set the size of the column 700 * @param string $newSize 701 */ 702 public function setSize($newSize) 703 { 704 $this->domain->setSize($newSize); 705 } 706 707 /** 708 * Returns the scale of the column 709 * @return string 710 */ 711 public function getScale() 712 { 713 return $this->domain->getScale(); 714 } 715 716 /** 717 * Set the scale of the column 718 * @param string $newScale 719 */ 720 public function setScale($newScale) 721 { 722 $this->domain->setScale($newScale); 723 } 724 725 /** 726 * Return the size in brackets for use in an sql 727 * schema if the type is String. Otherwise return an empty string 728 */ 729 public function printSize() 730 { 731 return $this->domain->printSize(); 732 } 733 734 /** 735 * Return a string that will give this column a default value. 736 * @return string 737 */ 738 public function getDefaultSetting() 739 { 740 $dflt = ""; 741 if ($this->getDefaultValue() !== null) { 742 $dflt .= "default "; 743 if (PropelTypes::isTextType($this->getType())) { 744 $dflt .= '\'' . $this->getPlatform()->escapeText($this->getDefaultValue()) . '\''; 745 } elseif ($this->getType() == PropelTypes::BOOLEAN) { 746 $dflt .= $this->getPlatform()->getBooleanString($this->getDefaultValue()); 747 } else { 748 $dflt .= $this->getDefaultValue(); 749 } 750 } 751 return $dflt; 752 } 753 754 /** 755 * Set a string that will give this column a default value. 756 */ 757 public function setDefaultValue($def) 758 { 759 $this->domain->setDefaultValue($def); 760 } 761 762 /** 763 * Get the raw string that will give this column a default value. 764 * @return string 765 * @see Domain::getDefaultValue() 766 */ 767 public function getDefaultValue() 768 { 769 return $this->domain->getDefaultValue(); 770 } 771 772 /** 773 * Get the default value suitable for use in PHP. 774 * @return mixed 775 * @see Domain::getPhpDefaultValue() 776 */ 777 public function getPhpDefaultValue() 778 { 779 return $this->domain->getPhpDefaultValue(); 780 } 781 782 /** 783 * Returns the class name to do input validation 784 */ 785 public function getInputValidator() 786 { 787 return $this->inputValidator; 788 } 789 790 /** 791 * Return auto increment/sequence string for the target database. We need to 792 * pass in the props for the target database! 793 */ 794 public function isAutoIncrement() 795 { 796 return $this->isAutoIncrement; 797 } 798 799 /** 800 * Return auto increment/sequence string for the target database. We need to 801 * pass in the props for the target database! 802 */ 803 public function isLazyLoad() 804 { 805 return $this->isLazyLoad; 806 } 807 808 /** 809 * Gets the auto-increment string. 810 * @return string 811 */ 812 public function getAutoIncrementString() 813 { 814 if ($this->isAutoIncrement()&& IDMethod::NATIVE === $this->getTable()->getIdMethod()) { 815 return $this->getPlatform()->getAutoIncrement(); 816 } elseif ($this->isAutoIncrement()) { 817 throw new EngineException("You have specified autoIncrement for column '" . $this->name . "' but you have not specified idMethod=\"native\" for table '" . $this->getTable()->getName() . "'."); 818 } 819 return ""; 820 } 821 822 /** 823 * Set the auto increment value. 824 * Use isAutoIncrement() to find out if it is set or not. 825 */ 826 public function setAutoIncrement($value) 827 { 828 $this->isAutoIncrement = (boolean) $value; 829 } 830 831 /** 832 * Set the column type from a string property 833 * (normally a string from an sql input file) 834 */ 835 public function setTypeFromString($typeName, $size) 836 { 837 $tn = strtoupper($typeName); 838 $this->setType($tn); 839 840 if ($size !== null) { 841 $this->size = $size; 842 } 843 844 if (strpos($tn, "CHAR") !== false) { 845 $this->domain->setType(PropelTypes::VARCHAR); 846 } elseif (strpos($tn, "INT") !== false) { 847 $this->domain->setType(PropelTypes::INTEGER); 848 } elseif (strpos($tn, "FLOAT") !== false) { 849 $this->domain->setType(PropelTypes::FLOAT); 850 } elseif (strpos($tn, "DATE") !== false) { 851 $this->domain->setType(PropelTypes::DATE); 852 } elseif (strpos($tn, "TIME") !== false) { 853 $this->domain->setType(PropelTypes::TIMESTAMP); 854 } else if (strpos($tn, "BINARY") !== false) { 855 $this->domain->setType(PropelTypes::LONGVARBINARY); 856 } else { 857 $this->domain->setType(PropelTypes::VARCHAR); 858 } 859 } 860 861 /** 862 * Return a string representation of the native PHP type which corresponds 863 * to the Creole type of this column. Use in the generation of Base objects. 864 * 865 * @return string PHP datatype used by propel. 866 */ 867 public function getPhpNative() 868 { 869 return PropelTypes::getPHPNative($this->propelType); 870 } 871 872 /** 873 * Returns true if the column's PHP native type is an 874 * boolean, int, long, float, double, string 875 */ 876 public function isPrimitive() 877 { 878 $t = $this->getPhpNative(); 879 return in_array($t, array("boolean", "int", "double", "string")); 880 } 881 882 /** 883 * Return true if column's PHP native type is an 884 * boolean, int, long, float, double 885 */ 886 public function isPrimitiveNumeric() 887 { 888 $t = $this->getPhpNative(); 889 return in_array($t, array("boolean", "int", "double")); 890 } 891 892 /** 893 * Get the platform/adapter impl. 894 * 895 * @return Platform 896 */ 897 public function getPlatform() 898 { 899 return $this->getTable()->getDatabase()->getPlatform(); 900 } 901 902 /** 903 * 904 * @return string 905 * @deprecated Use DDLBuilder->getColumnDDL() instead; this will be removed in 1.3 906 */ 907 public function getSqlString() 908 { 909 $sb = ""; 910 $sb .= $this->getPlatform()->quoteIdentifier($this->getName()) . " "; 911 $sb .= $this->getDomain()->getSqlType(); 912 if ($this->getPlatform()->hasSize($this->getDomain()->getSqlType())) { 913 $sb .= $this->getDomain()->printSize(); 914 } 915 $sb .= " "; 916 $sb .= $this->getDefaultSetting() . " "; 917 $sb .= $this->getNotNullString() . " "; 918 $sb .= $this->getAutoIncrementString(); 919 return trim($sb); 920 } 921 }
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 |