gpt4 book ai didi

php - Codeigniter select 始终返回顶行数据

转载 作者:行者123 更新时间:2023-11-29 12:52:10 24 4
gpt4 key购买 nike

我正在尝试从 tbl_customer_registration 获取 cus mobile,其中 cus_email 是从 $email 传递的。

换句话说,我想要获取客户手机,其中客户电子邮件等于$email

$this->db->select("tbl_customer_registration.cus_mobile");
$this->db->from('tbl_customer_registration');
$this->db->where('tbl_customer_registration.cus_email', $email);
$query = $this->db->get();
if ($query->num_rows() > 0) {
return $query->row_array();
} else {
return NULL;
}

enter image description here

它始终返回第一行 tbl_customer_registration.cus_mobile

这是他们返回的内容,这不是我需要的 cus_mobile

Array
(
[session_id] => ecf905ab051376563d3ce4140716d818
[ip_address] => ::1
[user_agent] => Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0
[last_activity] => 1404446526
[user_data] =>
[mobile] => 0712641946
[user_name] => podijobs@gmail.com
[is_logged_in] => 1
[cart_contents] => Array
(
[66eeaa0e65f3bf68db770c4c1b29891e] => Array
(
[rowid] => 66eeaa0e65f3bf68db770c4c1b29891e
[id] => SP004
[qty] => 1
[price] => 1500
[name] => Vegi Pizza Big
[image] => pizza-buena.jpg
[subtotal] => 1500
)
[total_items] => 1
[cart_total] => 1500
)
)

最佳答案

您需要使用函数 result() 或 result_array() 才能返回查询结果,例如:

foreach ($query->result_array() as $row)
{
echo $row['cus_mobile'];
}

如果您希望只返回一行,您还可以使用函数 row(),例如:

if ($query->num_rows() > 0)
{
$row = $query->row();
echo $row->cus_mobile;
}

关于php - Codeigniter select 始终返回顶行数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24555676/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com