Open
Description
setup
Model table has "id" column set as primary key, autoincrement
What steps will reproduce the problem?
$model = new Model();
$model->name = 'model name';
$model->save();
//this should return the id of newly inserted row to Model table,
//but returns the id of row inserted to Log table instead
echo $model->getPrimaryKey();
What is the expected result?
expected is a newly assigned id according to AutoIncremen PK
What do you get instead?
returns the id of row inserted to Log table instead
Additional info
Q | A |
---|---|
Yii version | 2.0.9 |
PHP version | 7.0.5 |
DB version | MariaDB 5.5 |
Operating system | Linux apache-data-it11-113 3.14.27-031427-generic #201412170558 SMP Wed Dec 17 11:00:01 UTC 2014 x86_64 |
config/web.php:
'log' => [
'traceLevel' => 0,//YII_DEBUG ? 3 : 0,
'flushInterval' => YII_DEBUG ? 1 : 100,
'targets' => [
[
'class' => 'yii\log\DbTarget',
'exportInterval' => YII_DEBUG ? 1 : 10,
'levels' => ['error', 'warning', 'profile' /*, 'info', 'trace', */],
'logVars' => [],
'categories' => [
'application',
'yii\db\*',
'yii\web\HttpException:*',
],
'except' => [
/*
'yii\web\HttpException:404',
'yii\web\HttpException:429',
*/
],
'prefix' => function ($message) {
$user = Yii::$app->has('user', true) ? Yii::$app->get('user') : null;
$userID = $user ? $user->getId(false) : '-';
return json_encode(['userid' => $userID]);
},
]
],
]