在 CodeIgniter 中仅从 MySQL 获取 1 行
Get 1 row only from MySQL in CodeIgniter
我想在调用它时只从数据库中取出 1 行,没有循环。
这是我在 CodeIgniter
上的代码
$row = $this->db->get_where('tr_supervision',array('EMP_ID_MEMBER' => $EMP_ID));
echo $row['EMP_ID_LEADER'];
我不知道怎么回事,但我得到了错误
遇到未捕获的异常
类型:错误
消息:无法将 CI_DB_mysqli_result 类型的对象用作数组
文件名:C:\laragon\www\onlineform\application\controllers\Reimbursement.php
行号:96
回溯:
文件:C:\laragon\www\onlineform\index.php
线路:315
函数:require_once
在这种情况下,您可以这样使用它:
$row = $this->db->where('EMP_ID_MEMBER',$EMP_ID)
->get('tr_supervision')
->row_array();
echo $row['EMP_ID_LEADER'];
请在此处详细了解查询结果:
https://codeigniter.com/userguide3/database/results.html?highlight=query%20results
$this->db->where('EMP_ID_MEMBER',$EMP_ID)
->get('tr_supervision')
->row_array();
我想在调用它时只从数据库中取出 1 行,没有循环。 这是我在 CodeIgniter
上的代码$row = $this->db->get_where('tr_supervision',array('EMP_ID_MEMBER' => $EMP_ID));
echo $row['EMP_ID_LEADER'];
我不知道怎么回事,但我得到了错误
遇到未捕获的异常 类型:错误
消息:无法将 CI_DB_mysqli_result 类型的对象用作数组
文件名:C:\laragon\www\onlineform\application\controllers\Reimbursement.php
行号:96
回溯:
文件:C:\laragon\www\onlineform\index.php 线路:315 函数:require_once
在这种情况下,您可以这样使用它:
$row = $this->db->where('EMP_ID_MEMBER',$EMP_ID)
->get('tr_supervision')
->row_array();
echo $row['EMP_ID_LEADER'];
请在此处详细了解查询结果: https://codeigniter.com/userguide3/database/results.html?highlight=query%20results
$this->db->where('EMP_ID_MEMBER',$EMP_ID)
->get('tr_supervision')
->row_array();