CodeIgniter Select Statement with Where clause

后端 未结 4 478
自闭症患者
自闭症患者 2021-01-28 17:55

Hi I\'m new to CodeIgniter and I just want to know How will I query from my MySql Db, a Select Statement with a where clause, I know it can be searched from the net but whenever

4条回答
  •  执念已碎
    2021-01-28 18:10

    You can do as Mehedi-PSTU stated, however it seems as though you're a little new to this, so here's some extra information:

    I'll copy Mehedi-PSTU for the most part here.

    $this->get->where('column_name', $equals_this_variable);
    $query = $this->db->get('table_name');
    

    This will store the query object in the variable $query. if you wanted to convert that to a usable array, you just perform to following.

    $results = $query->result_array();
    

    Or you can loop through it like this:

    foreach($query->result_array() as $result){
        // Perform some task here.
    }
    

    A better or even full understanding can probably come from:

    http://ellislab.com/codeigniter/user-guide/database/active_record.html

提交回复
热议问题