title: appending array in php / CodeIgniter
body: <p>I am try to append my data array in if conditions. I am using <code>array_push</code> function to do it Its first time I am using this function for appending array. I am using conditions so that if user has added the value in the form it would update the field otherwise It would not effect the field. The problem is its not updating the database and its unable to set the fields as it shows Unknown Unknown column '0' in 'field list'</p>
  
  <pre><code>$fid = 2;
  $password = "test_pass";
  $title = "new title of folder";
  $f_access = 1;
  $newName = TRUE;
  
  $data = array(
                'name' =&gt; $title,
                'access_type' =&gt; $f_access
                );
  
  if($newName)
  {
      $data2 = "'icon' =&gt; $newName";
      array_push($data, $data2);
  }
  
  if($password)
  {
      $data3 =   "'password' =&gt; $password";
      array_push($data, $data3);
  }
  
  $this-&gt;db-&gt;where('id', $fid);
  $this-&gt;db-&gt;update('folders', $data);
  </code></pre>