yes, that is correct.
sounds like you need to create another column in the table to mark the items as outOfStock or not, and modify the if statement so that items where the outOfStock column equals 1 show the message and 0 shows the add to cart button