Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i want to take only 1 row from database with no loop when i call it. this is my code on CodeIgniter

$row = $this->db->get_where('tr_supervision',array('EMP_ID_MEMBER' => $EMP_ID));
    
    echo $row['EMP_ID_LEADER'];

i dunno how but i get the error

An uncaught Exception was encountered Type: Error

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: C:laragonwwwonlineformapplicationcontrollersReimbursement.php

Line Number: 96

Backtrace:

File: C:laragonwwwonlineformindex.php Line: 315 Function: require_once


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
187 views
Welcome To Ask or Share your Answers For Others

1 Answer

In that case your use it like this:

$row = $this->db->where('EMP_ID_MEMBER',$EMP_ID)
         ->get('tr_supervision')
         ->row_array();

echo $row['EMP_ID_LEADER'];

Please read more about query results here: https://codeigniter.com/userguide3/database/results.html?highlight=query%20results


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...