我目前有以下查询给出了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;
}
答案 0 :(得分:0)
您可以将类型转换放在变量名之前,如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;
}