Php 将结果重新调整为字符串
我目前有一个查询,它给了我一个Php 将结果重新调整为字符串,php,mysql,codeigniter,Php,Mysql,Codeigniter,我目前有一个查询,它给了我一个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_
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;
}
呵呵!echo
spitsint(0)
?您是转储结果还是回显结果?是否确定使用echo或print?你忘了变量转储或打印吗