* added a getDefinition for columns and indexes - I am not very sure it's a very...
[vsc.git] / _res / _libs / models / foo / indexes / fookeyprimary.class.php
blob9eefcf1024682a8ae207eba37966017fadd69b8f
1 <?php
2 /**
3 * @package ts_models
4 * @author Marius Orcsik <marius@habarnam.ro>
5 * @date 09.04.27
6 */
8 class fooKeyPrimary extends fooIndexA {
9 public function __construct ($mIncomingStuff) {
10 /* @var $oField fooFieldA */
11 foreach ($mIncomingStuff as $oField) {
12 // enforcing NOT NULL constraints on the components of the primary key
13 if (fooFieldA::isValid($oField)) {
14 $oField->setIsNullable(false);
15 $aRet[] = $oField;
16 } else {
17 throw new fooIndexException('The object passed can not be used as a primary key.');
20 parent::__construct($aRet);
23 public function getName () {
24 return $this->name;
27 public function setName ($sName) {
28 $this->name = $sName . '_pk';
31 public function getType() {
32 return 'PRIMARY';
35 public function getDefinition () {
36 // this is totally wrong for PostgreSQL
37 return 'PRIMARY KEY ' . $this->getName() . ' (' . $this->getIndexComponents(). ')';