Commit de1df945 by João José

Typecast model id only if using mongodb AR class

parent 377b01d2
......@@ -433,11 +433,19 @@ class Generator extends \yii\gii\Generator
$class = $this->modelClass;
$pks = $class::primaryKey();
if (count($pks) === 1) {
return "'id' => (string)\$model->{$pks[0]}";
if (get_parent_class(new $class) == 'yii\mongodb\ActiveRecord') {
return "'id' => (string)\$model->{$pks[0]}";
} else {
return "'id' => \$model->{$pks[0]}";
}
} else {
$params = [];
foreach ($pks as $pk) {
$params[] = "'$pk' => (string)\$model->$pk";
if (get_parent_class(new $class) == 'yii\mongodb\ActiveRecord') {
$params[] = "'$pk' => (string)\$model->$pk";
} else {
$params[] = "'$pk' => \$model->$pk";
}
}
return implode(', ', $params);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment