Skip to content Skip to sidebar Skip to footer

How To Check Same Id Have Multiple Values In Another Column?

i have team member table and team table. In team member table have , three columns are there teamid, staff_id and stafftype(leader or technician). Only one leader (staff_type col

Solution 1:

MODEL :

publicfunctionadd_team_memb(){


    $this->db->select('NEXT VALUE FOR team_seq as team_id');
    $query = $this->db->get();

    foreach ($query->result_array() as$row) {
        $team_id = $row['team_id'];
    }

    $this->db->select('*');
    $this->db->from('team_member');
    $querySS = $this->db->get()->result();

    if(array_search('1', array_column($querySS, 'team_id')) !== false) {

        return1;
    }
    else {

        $datateam_memb = array(
            'team_id' => $team_id,
            'staff_id' => 3,
            'stafftype' => 'leader',

        );
        $insert_id = 0;
        if ($this->db->insert("team_member", $datateam_memb)) {
            $insert_id = $this->db->insert_id();
        }
        return$team_id;

    }


}

CONTROLLER ::

publicfunctionaddteammember()
{

    $value = $this->Admin_model->add_team_memb();

    if($value == 1)
    {
        ///pass message in view leader is already in team
    }
    else
    {
        $this->load->view('team_memb_creation');        
    }

}

Post a Comment for "How To Check Same Id Have Multiple Values In Another Column?"