asprin
Active member
So I'm creating a new table as part of my addon. In the setup file, I've the following code:
From reading other threads, I came across three kinds of declarations for adding a key:
I couldn't find the explanation of these formats in the docs. Any help as to which format will help me achieve my goal?
PHP:
public function installStep1()
{
$this->schemaManager()->createTable('xf_mytable', function(Create $table)
{
$table->addColumn('id_category', 'int')->autoIncrement();
$table->addColumn('category_title', 'varchar', '20')->setDefault('');
$table->addColumn('status_id', 'int'); // this is the intended foreign key column that would reference `xf_anothertable.id_status` column
$table->addPrimaryKey('id_category');
});
}
From reading other threads, I came across three kinds of declarations for adding a key:
PHP:
$table->addKey(['xxxxxx', 'yyyyy'], 'zzzzz'); // first format
$table->addKey('xxxxxx'); // second format
$table->addKey(['xxxxx', 'yyyyy']); // third format
I couldn't find the explanation of these formats in the docs. Any help as to which format will help me achieve my goal?