知道为什么这不起作用吗?我正在获取用户设置的标签,并希望获取具有相同标签的其他用户的 ID。
控制器:
$this->load->model('tag_model');
$data['usr_tags'] = $this->tag_model->get_home_tags($user_id);
$tags = $this->tag_model->get_home_tags($user_id);
$tag_array = $tags;
$data['tag_users'] = $this->tag_model->get_tag_users($tag_array);
模型:
function get_tag_users($tag_array)
{
//$tag = array('item1','item2','item3');
$tag = $tag_array;
$query_str = 'SELECT DISTINCT user_id FROM tags WHERE tag IN ("'. implode('","', $tag) .'")';
$query = $this->db->query($query_str);
if($query->num_rows() > 0) {
foreach($query->result_array() as $tag_users) {
$data[] = $tag_users;
}
return $data;
}else{
return false;
}
}
错误:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: models/tag_model.php
Line Number: 20