Updating multiple identifiers in the code

I want to update the data to several identifiers, I take all identifiers

controller

    public function getIds(){
    for($i=0;$i<count($_POST['std_id']);$i++){
        echo $_POST['std_id'][$i];
        $student_id[]=$_POST['std_id'][$i];
    } 

I do not know how to update this?

How to write a modal function?

+4
source share
1 answer

You do not need to create a separate array for this. You can pass $_POST['std_id]that has an ids array .

controller

$this->modelname->mymethod($_POST['std_id'],$updateData);

where $_POST['std_id']is an array of identifiers and $updateDatafor updating fields

model

function mymethod($idArr,$data){
    $this->db->where_in("fieldname", $idArr);
    $this->db->update("tablename",$data);
}

you can use where_infor mysql INto check multiple ids.

+2
source

Source: https://habr.com/ru/post/1612874/


All Articles