I'm trying to create a hierarchy of SQL
query objects. My base class will be named Query. It will have methods like Query.setTable("tableName")
.
Then I plan on having a SelectiveQuery
object extend the Query object. This object will have methods like SelectiveQuery.where("aColumn","=","123")
.
Then I plan on having UpdateQuery
, SelectQuery
, DeleteQuery
, and CountQuery
all extend SelectiveQuery
. My dilemma arises when I try to figure out how to create the InsertQuery
class. I want it to extend Query but not extend SelectiveQuery
.
The kicker is that InsertQuery
and UpdateQuery
will share some of the same methods, such as setValue("aColumn","aValue")
. I'd prefer to only maintain the methods UpdateQuery
and InsertQuery
have in common in one location. How do I tackle this? If I were programming in PHP
. I think I'd use Traits to do this.