<?php
require_once 'config.php';
require_once 'database.php';
class brandClear extends database
{
   public function index()
    {
		return $this->fetchAll('tb_brands', null, 'cl_created_at', 'DESC');
	}

	public function updateNullOnImage($id)
	{
		return $this->update('tb_brands', ['cl_image' => null], ['cl_id' => $id]);
	}
}


$obj = new brandClear();

$brands = $obj->index();

echo count($brands);
echo '<br/>';

foreach($brands AS $brand)
{
	if($brand['cl_image'] != null)
	{
		echo $brand['cl_image'];
		if (!file_exists('../uploads/brands/' . $brand['cl_image'])) {
			echo 'No';
			$obj->updateNullOnImage($brand['cl_id']);
 		}
 		else
 		{
 			echo 'Yes';
 		}
	}
}