title: insert or replace in codeigniter
body: <p>I want to insert of replace if exist in database with codeigniter
  this my model</p>
  
  <pre><code>public function upload($id_akun,$data){
                 $query = $this-&gt;db-&gt;query("SELECT * FROM akun WHERE
  id_akun = '{$data['id_akun']}' ");
  $result = $query-&gt;result_array();
  $count = count($result);
  
  if (empty($count)) {
  
       $this-&gt;db-&gt;insert('foto', $data);  
  }
  elseif ($count == 1) {
     $this-&gt;db-&gt;where('id_akun', $data['id_akun']);
                      $this-&gt;db-&gt;update('foto', $data);  
  }
  </code></pre>
  
  <p>I'm succesful replace(update) data if exist but it not inserting data if (empty($count))</p>
  
  <p>conditional ($count == 1)---> it's ok
  condtional (empty($count))--->problem?</p>