title: How to get auto increment id after save in Yii2
body: <p>Im trying to get auto increment id after save in Yii2.I tried to the following code block but its not working.</p>
  
  <pre><code>public function actionAddgroup()
  {
      $model = new Groups();
      $model-&gt;groupName=Yii::$app-&gt;request-&gt;post('groupName');
  
      $model-&gt;save();  // a new row is inserted into user table
      return $model-&gt;id;
  }
  </code></pre>