+ $this->mDb = null;
+ $this->resetQueryParams();
+ }
+
+ protected function resetQueryParams() {
+ $this->tables = array ();
+ $this->where = array ();
+ $this->fields = array ();
+ $this->options = array ();
+ }
+
+ protected function addTables($tables, $alias = null) {
+ if (is_array($tables)) {
+ if (!is_null($alias))
+ ApiBase :: dieDebug(__METHOD__, 'Multiple table aliases not supported');
+ $this->tables = array_merge($this->tables, $tables);
+ } else {
+ if (!is_null($alias))
+ $tables = $this->getDB()->tableName($tables) . ' ' . $alias;
+ $this->tables[] = $tables;
+ }
+ }
+
+ protected function addFields($value) {
+ if (is_array($value))
+ $this->fields = array_merge($this->fields, $value);
+ else
+ $this->fields[] = $value;
+ }
+
+ protected function addFieldsIf($value, $condition) {
+ if ($condition) {
+ $this->addFields($value);
+ return true;
+ }
+ return false;
+ }
+
+ protected function addWhere($value) {
+ if (is_array($value))
+ $this->where = array_merge($this->where, $value);
+ else
+ $this->where[] = $value;
+ }
+
+ protected function addWhereIf($value, $condition) {
+ if ($condition) {
+ $this->addWhere($value);
+ return true;
+ }
+ return false;
+ }
+
+ protected function addWhereFld($field, $value) {
+ if (!is_null($value))
+ $this->where[$field] = $value;