Yii php : Remove duplicates in the database and update the duplicate row -


i'm using yii php , have problem duplicate entries in database.

to demonstrate, suppose have this:

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 ------------------------------------------------------------------------ 

technically, parent1 same, used both female , male. above correct inefficient, duplication not necessary since pertain same parent. how remove duplicate parent1 , update first row is_female true?

such result :

id(pk) | parent_id | parent_name| is_male(boolean) | is_female(boolean) ------------------------------------------------------------------------ 1      |     1     |parent1     | true             | true                 ------------------------------------------------------------------------ 3      |     2     |parent2     | false            | true ------------------------------------------------------------------------ 

how do programmatically in yii php? thanks!

    in update mode loadmodel query change means no need delete duplicated , first record updated     controller file  ----------------               function loadmodel($id)            {     $where='id='.$id .' group parent_id '     $model=model()->find($where);            }      in view file      ------------             <?php             if($model->parent_id==1)  // when parent_id 1 female field visible , sure not  affect created              {              echo $form->textfield($model, 'is_female'); ?>             }          ?> 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -