Codeigniter $this->db->get(), how do I return values for a specific row?

前端 未结 5 1393
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 19:19

Say I have a database table with three columns: ID, Name, and Age. I need to find the user with a specific (unique) ID, and then return the age. Currently, I am using the fo

5条回答
  •  臣服心动
    2020-12-07 19:55

    Incase you are dynamically getting your data e.g When you need data based on the user logged in by their id use consider the following code example for a No Active Record:

     $this->db->query('SELECT * FROM my_users_table WHERE id = ?', $this->session->userdata('id'));
    
     return $query->row_array();
    

    This will return a specific row based on your the set session data of user.

提交回复
热议问题