yii2에 문제가있어서 도움이 필요합니다. 저는 MsSQL db1과 db2에 2 개의 데이터베이스를 가지고 있는데, db2에는 db1 테이블에 대한 뷰가 있습니다. 문제는 내가 db2에 삽입 할 때 $ model-> id 또는 $ model-> getPrimaryKey()를 사용하여 트랜잭션 ID를 가져올 수 없다는 것입니다. 누구든지이 문제를 해결하는 방법을 알고 있습니까? 이 내 모델 : 많은 조사와 yii2의 소스 코드의 수정 후다른 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