I want to insert image to Database but I want to check if there is already stored image or not. If no image before, update the database, if there is image in database, update database and unlink prev image.
$stmt = $db->query("SELECT COUNT(*) FROM pr_journalist WHERE id='".$id."' AND foto='' ");
    
    
    if($stmt = 0) {
    
        // Insert image file name into database
            $insert = $db->query("UPDATE pr_journalist SET foto='".$fileName."' WHERE id='".$id."'");
        
                        
        unlink("uploads/".$foto);
           $statusMsg = 'ok';
       
        }else{
        // Insert image file name into database
            $insert = $db->query("UPDATE pr_journalist SET foto='".$fileName."' WHERE id='".$id."'");
       
                        
           $statusMsg = 'ok';
        
    }
With my above code, counting Row always make me to one if condition, although im trying to change to foto IS NOT NULL and change if condition to != 0 or foto IS NULL with if = 0. It is like if ($stmt = 0) always got the same value from row count.
 
    