'Object of class could not be converted to string error

I am receiving the following error below on the object's function in Smarty and I am unaware of how to resolve the issue.

Error:

Catchable fatal error: Object of class users_class could not be converted to string

This is the following object and function of the object I am using.

class users_class
{
    public function fetchUser(array $conditions)
    {
        $db = Core::getInstance();
        $sql = "SELECT * FROM ".USERS." WHERE ";
        $i=0;
        $params = array();
        //$where = array();
        foreach ($conditions as $column => $value)
        {
            if (preg_match('/^[a-z-.-_]+$/', $column)) {
                if ($i!=0) {
                    $sql .= " AND ";
                }
                $sql .= "$column = ?";
                $params[] = $value;
                $i++;
            }
        }           
        //$sql .= implode(' AND ', $where);
        //$sql .= " order by title asc";    
        $res = $db->dbh->prepare($sql);
        $res->execute(array_values($params));
        return $res->fetch(PDO::FETCH_ASSOC);               
    }
}

This is the call in Smarty:

 {section name=ststval loop=$ststres}
    {if $ststres[ststval].type == 2}
       {assign var='udatas' value="$userObj->fetchUser(array('id'=>$ststres[ststval].to_id));"}
php


Solution 1:[1]

To convert an object to a string in this way, you need a magic __toString() method defined

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mark Baker