/** * generate sql string * * @return string * @throws base_database_Exception */ public function toString() { $result = 'DELETE FROM '; $result .= $this->table->getName(); if (empty($this->where)) { throw new base_database_Exception(TMS(base_database_Exception::NO_WHERE_GIVEN)); } $result .= ' WHERE '; $result .= $this->where->toString(); return $result; }
/** * generate sql string * * @return string */ public function toString() { $result = 'UPDATE '; $result .= $this->table->getName(); $result .= ' SET '; if (empty($this->columnValues) === false) { $result .= implode(', ', $this->columnValues); } if (empty($this->where) === false) { $result .= ' WHERE '; $result .= $this->where->toString(); } return $result; }
/** * return the statement in string format * * @return string */ public function toString() { $result = 'SELECT '; $columnNames = $this->_getColumnNames(); if (empty($columnNames) === true) { $result .= '*'; } else { $result .= implode(', ', $columnNames); } $result .= ' FROM '; $result .= $this->table->getName(); if (isset($this->where) === true) { $result .= ' WHERE '; $result .= $this->where->toString(); } if (isset($this->order) === true) { $result .= ' ORDER BY '; $result .= $this->order->toString(); } if (isset($this->limit) === true) { $result .= ' LIMIT '; $result .= $this->limit->toString(); } return $result; }
public function count($historic = false) { $columns = array($this->table->getColumn('LK')); if ($historic == false) { if (empty($this->where)) { $this->where = DB::where($this->table->getColumn('histtop'), DB::term('Y')); } else { $this->where->addAnd($this->table->getColumn('histtop'), DB::term('Y')); } } if (empty($this->order)) { $this->order = new base_database_Order($this->table->getColumn('LK'), base_database_Order::ASC); } $select = $this->_createSelectStatement($columns); $result = $select->fetchDatabase(); return count($result); }