<?php

/**
 * SQL Dialect for SQL92 compatible RDBMS
 *
 * Works fine with PostgreSQL. Should work with Oracle, DB2 and Informix as well.
 *
 * @version DR1.4
 */
class SQL92Dialect extends SQLDialect {



	public function getTrue() {
		return 'true';
	}



	public function getFalse() {
		return 'false';
	}



	public function getQuotes() {
		return '"';
	}



	public function getSQL($sql, $order, $descending, $offset, $limit) {
		if ($order) {
			$asc = $descending ? 'DESC' : 'ASC';
			$sql .= stristr($sql, 'ORDER')
				? ", $order $asc"
				: " ORDER BY $order $asc";
		}
		if ($offset) {
			if (stristr($sql, 'OFFSET')) {
				$sql = preg_replace('/OFFSET.*/', " OFFSET $offset", $sql);
			} else {
				$sql .= " OFFSET $offset";
			}
		}
		if ($limit) {
			if (stristr($sql, 'LIMIT')) {
				$sql = preg_replace('/LIMIT.*/', " LIMIT $limit", $sql);
			} else {
				$sql .= " LIMIT $limit";
			}
		}
		return $sql;
	}



} // class SQL92Dialect

?>