title: Yii php : Remove duplicates in the database and update the duplicate row
body: <p>i'm using Yii php and i have a problem with duplicate entries in the database. </p>
  
  <p>to demonstrate, suppose i have this:</p>
  
  <pre><code>id(pk) | parent_id | parent_name| is_male(boolean) | is_female(boolean)
  ------------------------------------------------------------------------
  1      |     1     |parent1     | true             | false                
  ------------------------------------------------------------------------
  2      |     1     |parent1     | false            | true
  ------------------------------------------------------------------------
  3      |     2     |parent2     | false            | true
  ------------------------------------------------------------------------
  </code></pre>
  
  <p>Technically, the parent1 is the same, but used as both female and male. <strong>Above is correct but inefficient</strong>, the duplication is not necessary since they only pertain to the same parent. How do i <strong>remove the duplicate parent1</strong> and just update the first row <strong>is_female</strong> to <strong>true</strong>?</p>
  
  <p>such as to result to :</p>
  
  <pre><code>id(pk) | parent_id | parent_name| is_male(boolean) | is_female(boolean)
  ------------------------------------------------------------------------
  1      |     1     |parent1     | true             | true                
  ------------------------------------------------------------------------
  3      |     2     |parent2     | false            | true
  ------------------------------------------------------------------------
  </code></pre>
  
  <p>How do i do this programmatically in Yii php? Thanks!</p>