title: Inserting array into database Yii
body: <p>I would like to insert an array into a MYSQL database, preferably using Yii's active record.</p>
  
  <p>For example, I have a an array:</p>
  
  <pre><code>User = array(
      fname =&gt; "Joe"
      lname =&gt; "Schmidt"
  )
  </code></pre>
  
  <p>with a User table in my database with columns id, fname and lname. One of the options is creating an object and doing:</p>
  
  <pre><code>$user = new User;
  $user-&gt;fname = User['fname'];
  $user-&gt;lname = User['lname'];
  $user-&gt;save();
  </code></pre>
  
  <p>However, this seems like so much code for such common functionality. Is there a way to insert an array into the database where array keys match corresponding columns without me writing my own function or doing some SQL query hack? Ideally it uses the already present Active record of Yii.</p>