title: Run forloop in yii model action create and save every record although forloop ends
body: <p>I need to run forloop in yii model action create or Addipblock()  and save every record although forloop end and then redirect it to view admin,</p>
  
  <p>My first record take start from 1 and end 50, So in database should be 50 records added.</p>
  
  <p>My code is like this:</p>
  
  <pre><code>`public function actionAddipblock(){        
      $model=new IpManager('addipblock'); 
      if(isset($_POST['IpManager'])){
          $model-&gt;attributes=$_POST['IpManager'];         
          $starting_ip = $_POST['IpManager']['starting_ip'];
          $ending_ip   = $_POST['IpManager']['ending_ip'];            
          if($model-&gt;validate('addipblock')){             
          for($ip = $starting_ip; $ip &lt;= $ending_ip; $ip++){
              $model-&gt;ip = $ip;
              $model-&gt;server = $_POST['IpManager']['server'];
              $model-&gt;client = $_POST['IpManager']['client'];
              $model-&gt;status = $_POST['IpManager']['status'];
              $model-&gt;creation_date = date("Y-m-d H:i:s");
          }           
          if($model-&gt;save()){ 
                 $this-&gt;redirect(array('admin'));     
           }
            else{
                  echo 'Error:';
              }               
          }
      }
      $this-&gt;render('addipblock',array('model'=&gt;$model));
  }` 
  </code></pre>
  
  <p>But when I run this code it save only one record not save all recorde until forloop end.
  Guys what will you suggest me for this? what should I can do for this?</p>