无法添加新的图像PHP / Mysql

I want to make it possible to update the hostage image with a new image but it's not working. It's using AJAX to send the data to the database. I get the following response from AJAX:

Temp/Thumb/6587_1480425818.pngimages
/acomodate/172/thumbnail/7483_1480052721.png
images/acomodate/172/thumbnail/2243_1480052767.png

And I am using the code below to add new images to the database. But when I run it nothing happens. It's not inserting the data into the table.

$r = $_REQUEST['id'];
$db21 = new Database();
$db21->connect();
$services = explode(',', $_REQUEST['allimg']);
$tot_ser = count($services);

for ($i = 0; $i < $tot_ser - 1; $i++)
{
echo $imgpath0 = $services[$i];
$ar0 = explode('/', $imgpath0);
$imgpath0 = $ar0[2];
if (!file_exists('../../images/acomodate/' . $r . '/'))
    {
    mkdir('../../images/acomodate/' . $r . '/', 0777, TRUE);
    }

if (!file_exists('../images/acomodate/' . $r . '/thumbnail/'))
    {
    mkdir('../images/acomodate/' . $r . '/thumbnail/', 0777, TRUE);
    }

rename('Temp/' . $imgpath0, '../images/acomodate/' . $r . '/');
rename('Temp/Thumb/' . $imgpath0, '../images/acomodate/' . $r . '/thumbnail/');
$db21->update('hostimages', array($r, $imgpath0) , 'hostid','image');
}

edit Database class for update

public function update($table,$rows,$where)
{                
    if($this->tableExists($table))
    {
        // Parse the where values
        // even values (including 0) contain the where rows
        // odd values contain the clauses for the row
        for($i = 0; $i < count($where); $i++)
        {
            if($i%2 != 0)
            {                    
                if(is_string($where[$i]))
                {
                    if(($i+1) != null)
                        $where[$i] = '"'.$where[$i].'"';
                    else
                        $where[$i] = '"'.$where[$i].'" AND';
                }
            }
        }

        $where = implode('',$where);


        $update = 'UPDATE '.$table.' SET ';
        $keys = array_keys($rows);
        for($i = 0; $i < count($rows); $i++)
        {
            if(is_string($rows[$keys[$i]]))
            {
                $update .= $keys[$i].'="'.$rows[$keys[$i]].'"';
            }
            else
            {
                $update .= $keys[$i].'='.$rows[$keys[$i]];
            }

            // Parse to add commas
            if($i != count($rows)-1)
            {
                $update .= ',';
            }
        }
        $update .= ' WHERE '.$where;
  //  echo $update;

         $query = @mysql_query($update);

        if($query)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    else
    {
        return false;
    }
}

Can you guys help me with it? Thank you.