Fix some sql name in the code php and add logic if array is empty dont do anything