У меня проблема с yii2, и мне нужна помощь: У меня есть 2 базы данных в MsSQL db1 и db2, в db2 У меня есть вид таблицы db1. Проблема в том, что когда я вставляю в db2, я не могу получить идентификатор транзакции, используя $ model-> id или $ model-> getPrimaryKey(). Кто-нибудь знает, как это решить? это моя модель:вставка в виде таблицы в другом db
<?php
namespace app\models;
use Yii;
class Documents extends \yii\db\ActiveRecord
{
public static function primaryKey()
{
return ['id'];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'documents';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['realname', 'size'], 'required'],
[['realname'], 'string'],
[['size'], 'integer'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'realname' => 'Realname',
'size' => 'Size',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocumentSchoolRegistrationToInsurances()
{
return $this->hasMany(DocumentSchoolRegistrationToInsurance::className(), ['document' => 'id']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getDocumentSchoolregistrations()
{
return $this->hasMany(DocumentSchoolregistration::className(), ['document' => 'id']);
}
}
Что вы пытались? –
$ model-> id и $ model-> PrimaryKey() – Yordankis