Reputation: 3226
I have an array which I want to use in a query:
Array ( [0] => stdClass Object ( [followee] => 267,269,270,271,272,273,275,276,277,278,279 ) )
I'm not sure why it returns the message:
Object of class stdClass could not be converted to string.
Controller:
$data['activity'] = $this->home_model->activity($followID);
Model:
function activity($followID)
{
$query_str = 'SELECT DISTINCT name
FROM place
WHERE userid IN ("'. implode('","', $followID) .'")';
$query = $this->db->query($query_str);
Upvotes: 2
Views: 4580
Reputation: 8020
Well, you have an object in you variable and you don't want to convert that.
The right way, to access the variable would be creating a function inside your class like this:
public function getFollowee() {
return $this -> followee;
}
And the way to access it:
function activity() {
$query_str = 'SELECT DISTINCT name FROM place WHERE userid IN ( ' . $stdClass -> getFollowee() . ')';
$query = $this -> db -> query( $query_str );
}
Upvotes: 0