gpt4 book ai didi

php - 将结果重新调整为字符串

转载 作者:行者123 更新时间:2023-11-29 23:48:21 26 4
gpt4 key购买 nike

我目前有以下查询,它给出的结果是 int(0) 我怎样才能得到 0 的结果?

代码:

public function check_manufacturer_id($manufacturer_id)
{
$table = $this->_table_products_manufacturers;
$query = $this->db->query("SELECT $table.id FROM $table WHERE $table.id = $manufacturer_id");
$result = $query->num_rows();

return $result;
}

最佳答案

您可以将类型转换放在变量名称之前,如下所示 return (string)$result;

使用您的代码:

public function check_manufacturer_id($manufacturer_id)
{
$table = $this->_table_products_manufacturers;
$query = $this->db->query("SELECT $table.id FROM $table WHERE $table.id = $manufacturer_id");
$result = $query->num_rows();

return (string)$result;
}

关于php - 将结果重新调整为字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25796686/

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