CodeIgniter - return only one row?

后端 未结 10 1351
鱼传尺愫
鱼传尺愫 2020-12-01 02:43

At the moment if I am doing a query on the database that should only return one row, using:

...query stuff...
$query = $this->db->get();
$ret = $query-         


        
10条回答
  •  一整个雨季
    2020-12-01 03:10

    To make the code clear that you are intending to get the first row, CodeIgniter now allows you to use:

    if ($query->num_rows() > 0) {
        return $query->first_row();
    }
    

    To retrieve the first row.

提交回复
热议问题