title: Yii: save multiple records in one query
body: <p>I'm trying to save a lot of CActiveRecord model objects in a loop.
  I have something like this:</p>
  
  <pre><code>foreach ($array_of_items as $item) {
  
      $values = array(
          "title"   =&gt; $item-&gt;title,
          "content" =&gt; $item-&gt;content,
      );
  
      $object = new MyModel;
      $object-&gt;attributes = $values;
      $object-&gt;save();
  
  }
  </code></pre>
  
  <p>In my case, this creates about 400 CActiveRecord objects. The saving process is really slow, because each <strong>save()</strong> queries the database.</p>
  
  <p>Is there a way to save all those objects in one go?
  Something like:</p>
  
  <pre><code>$objects = array();
  
  foreach ($array_of_items as $item) {
  
      $values = array(
          "title"   =&gt; $item-&gt;title,
          "content" =&gt; $item-&gt;content,
      );
  
      $object = new MyModel;
      $object-&gt;attributes = $values;
      $objects[] = $object;
  }
  
  save_all_objects($objects);
  </code></pre>
  
  <p>I could not find anything on the subject. Anyone?</p>