Пример #1
0
 public function testGetDatabaseTable()
 {
     $field1 = new PropertyField('field1', 'type');
     $field2 = new PropertyField('field2', 'type');
     $field3 = new HasManyField('field3', 'model');
     $index = new Index('field2', array($field2));
     $modelTable = new ModelTable('table');
     $modelTable->addField($field1);
     $modelTable->addField($field2);
     $modelTable->addField($field3);
     $modelTable->addIndex($index);
     $pk = new PropertyField('id', 'pk');
     $pk->setIsAutonumbering(true);
     $pk->setIsPrimaryKey(true);
     $databaseTable = new Table('table');
     $databaseTable->addField($pk);
     $databaseTable->addField($field1);
     $databaseTable->addField($field2);
     $databaseTable->addIndex($index);
     $this->assertEquals($databaseTable, $modelTable->getDatabaseTable());
 }
Пример #2
0
 /**
  * Construct this model definition
  * @param string $name name of the model
  * @param boolean $isLogged set to true to log this model
  * @return null
  */
 public function __construct($name, $isLogged = false)
 {
     $this->setName($name);
     $this->setIsLogged($isLogged);
     $this->isLocalized = false;
     $this->fields = array();
     $this->indexes = array();
     $this->dataFormats = array();
     $this->willBlockDeleteWhenUsed = false;
     $primaryKey = new PropertyField(self::PRIMARY_KEY, Field::TYPE_PRIMARY_KEY);
     $primaryKey->setIsAutoNumbering(true);
     $primaryKey->setIsPrimaryKey(true);
     $this->addField($primaryKey);
 }