Exemple #1
0
 /**
  * @param string $name
  * @param mixed $primaryKey available only for create table
  * true - if you want classic autoincrement integer primary column with name id
  * Column - if you want to define your own column (column is added to list of columns)
  * string - name of column in list of columns
  * array of strings - names of columns in list of columns
  * array of Column - list of own columns (all columns are added to list of columns)
  * other (false, null) - if your table doesn't have primary key
  * @return AbstractMigration
  * @throws IncorrectMethodUsageException
  */
 protected final function table($name, $primaryKey = true, $charset = null, $collation = null)
 {
     if ($this->table !== null) {
         throw new IncorrectMethodUsageException('Wrong use of method table(). Use one of methods create(), drop(), save() first.');
     }
     $this->primaryKey = $primaryKey;
     $this->table = new Table($name);
     $this->table->setCharset($charset ?: $this->adapter->getCharset());
     $this->table->setCollation($collation);
     return $this;
 }