/** * 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; }
private function _setLimit() { $limitValue = (int) $this->params['limit']; $page = (int) $this->params['page']; $offset = $limitValue * ($page - 1); $limit = new base_database_Limit($limitValue); $limit->setOffset($offset); $this->limit = $limit; }