Changeset 333
- Timestamp:
- 03/04/07 13:29:05 (2 years ago)
- Files:
-
- trunk/src/main/php/net/stubbles/rdbms/persistence/annotations/stubDBColumnAnnotation.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreator.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableColumn.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableDescription.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/rdbms/persistence/annotations/stubDBColumnAnnotation.php
r246 r333 19 19 { 20 20 /** 21 * order of column within table 22 * 23 * @var int 24 */ 25 protected $order = 0; 26 /** 21 27 * name of the column 22 28 * … … 81 87 { 82 88 return stubAnnotation::TARGET_METHOD; 89 } 90 91 /** 92 * set the order within the table 93 * 94 * @param int $order 95 */ 96 public function setOrder($order) 97 { 98 $this->order = $order; 99 } 100 101 /** 102 * returns the order within the table 103 * 104 * @return int 105 */ 106 public function getOrder() 107 { 108 return $this->order; 83 109 } 84 110 trunk/src/main/php/net/stubbles/rdbms/persistence/creator/stubDatabaseCreator.php
r324 r333 104 104 $methods = $refClass->getMethods(); 105 105 foreach ($methods as $method) { 106 if ($method->hasAnnotation('DBColumn') == false || $method->getDeclaringClass()->equals($refClass) == false) {106 if ($method->hasAnnotation('DBColumn') == false) { 107 107 continue; 108 108 } elseif ($method->hasAnnotation('DBTable') == true && $method->getAnnotation('DBTable')->getName() != $tableDescription->getName()) { … … 112 112 $dbColumn = $method->getAnnotation('DBColumn'); 113 113 $columnDescription = new stubDatabaseTableColumn(); 114 $columnDescription->setOrder($dbColumn->getOrder()); 114 115 $columnDescription->setName($dbColumn->getName()); 115 116 $columnDescription->setType($dbColumn->getType()); trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableColumn.php
r316 r333 16 16 { 17 17 /** 18 * order of column within table 19 * 20 * @var int 21 */ 22 protected $order = 0; 23 /** 18 24 * name of the table 19 25 * … … 75 81 */ 76 82 protected $isKey = false; 83 84 /** 85 * set the order within the table 86 * 87 * @param int $order 88 */ 89 public function setOrder($order) 90 { 91 $this->order = $order; 92 } 93 94 /** 95 * returns the order within the table 96 * 97 * @return int 98 */ 99 public function getOrder() 100 { 101 return $this->order; 102 } 77 103 78 104 /** trunk/src/main/php/net/stubbles/rdbms/querybuilder/stubDatabaseTableDescription.php
r316 r333 25 25 * columns of the table 26 26 * 27 * @var array< string,stubDatabaseTableColumn>27 * @var array<int,stubDatabaseTableColumn> 28 28 */ 29 29 protected $columns = array(); 30 30 /** 31 * columns of table sorted by name 32 * 33 * @var array<string> 34 */ 35 protected $columnNames = array(); 36 /** 37 * the column order counter 38 * 39 * @var int 40 */ 41 protected $columnOrder = 1; 42 /** 31 43 * type of the table 32 44 * … … 80 92 public function addColumn(stubDatabaseTableColumn $column) 81 93 { 82 $this->columns[$column->getName()] = $column; 94 if (in_array($column->getName(), $this->columnNames) == true) { 95 throw new stubDatabaseException('The column ' . $column->getName() . ' already exists in table ' . $this->getName()); 96 } 97 98 $this->columnNames[] = $column->getName(); 99 $order = $column->getOrder(); 100 if (0 == $order) { 101 $order = $this->columnOrder; 102 $this->columnOrder++; 103 } 104 105 if (isset($this->columns[$order]) == true) { 106 throw new stubDatabaseException('Can not add column ' . $column->getName() . ' with order ' . $order . ', there is already column ' . $this->columns[$order]->getName() . ' at this place.'); 107 } 108 109 $this->columns[$order] = $column; 83 110 } 84 111 … … 90 117 public function getColumns() 91 118 { 119 ksort($this->columns); 92 120 return $this->columns; 93 121 }
