I've structured my Record as such:
<?php
namespace Craft;
class MyPlugin_MerchantOrderRecord extends BaseRecord
{
public function getTableName()
{
return 'myplugin_merchant_orders';
}
protected function defineAttributes()
{
return [
'merchant_id' => AttributeType::Number,
'order_id' => AttributeType::Number,
...
];
}
public function primaryKey()
{
return ['merchant_id', 'order_id'];
}
public function defineRelations()
{
return [
'merchant' => [static::BELONGS_TO, 'MyPlugin_MerchantRecord', 'merchant_id',
'required' => true, 'onDelete' => static::CASCADE],
'order' => [static::BELONGS_TO, 'Commerce_OrderRecord', 'order_id',
'required' => true, 'onDelete' => static::CASCADE],
];
}
}
When I install the plugin I get the following error:
Illegal offset type in isset or empty
If I take away the primaryKey()
definition, the table is created successfully and the foreign keys
are in place as expected.
Any help gratefully received.