2
私は主キーの複製があるエントリを挿入します。なぜYii2がtry/catchでダウンしていますか?
public function actionInc()
{
$add = new Country();
$add->code = 'QI';
$add->name = 'Qiang';
$add->population = '4444444';
try {
$add->save();
return $this->render('inc', [
'count' => 'Ok',
]);
} catch (Exception $exception) {
return $this->render('inc', [
'count' => 'Error',
]);
}
}
しかし、私は、アプリケーションがダウンしない、と仕事を続けたが、それが動作しないことを必要とする...例外サブクラスは、あなたの使用文
のYiiにインポートしている
から継承しますか? – csminb
@csminb動作します。あなたのコメントは私がそれをマークできるように応答してください。 – fosh4455