Decouple SQL queries from class in OOP design



To my knowledge, in OOP design it's not good to mix SQL queries with
application codes in classes, because it limits the usability of the
classes and bound them to the local database schema. But I am not sure
what the best way is to decouple them. The method that I am using right
now is to create a hash to store all the SQL statements and prepare
them in the main program, then I will pass this hash as a variable to
all the classes that are going to use it. I am not sure whether there
is any better design. Thanks in advance!

.