Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
    /**
     * 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;
    }