From 1cecbabe2fddb337a6ad7b4e2fd65052e759f878 Mon Sep 17 00:00:00 2001 From: Dominik Liebler Date: Fri, 6 Jun 2014 09:37:13 +0200 Subject: [PATCH] readded in correct case --- Structural/FluentInterface/Sql.php | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Structural/FluentInterface/Sql.php diff --git a/Structural/FluentInterface/Sql.php b/Structural/FluentInterface/Sql.php new file mode 100644 index 0000000..3afd300 --- /dev/null +++ b/Structural/FluentInterface/Sql.php @@ -0,0 +1,80 @@ +fields = $fields; + + return $this; + } + + /** + * adds a FROM clause + * + * @param string $table + * @param string $alias + * + * @return SQL + */ + public function from($table, $alias) + { + $this->from[] = $table . ' AS ' . $alias; + + return $this; + } + + /** + * adds a WHERE condition + * + * @param string $condition + * + * @return SQL + */ + public function where($condition) + { + $this->where[] = $condition; + + return $this; + } + + /** + * Gets the query, just an example of building a query, + * no check on consistency + * + * @return string + */ + public function getQuery() + { + return 'SELECT ' . implode(',', $this->fields) + . ' FROM ' . implode(',', $this->from) + . ' WHERE ' . implode(' AND ', $this->where); + } +}