@@ 20-49 (lines=30) @@ | ||
17 | /** |
|
18 | * Class Select |
|
19 | */ |
|
20 | class Select extends SelectAbstract{ |
|
21 | ||
22 | /** |
|
23 | * @return string |
|
24 | * @throws \chillerlan\Database\Query\QueryException |
|
25 | */ |
|
26 | public function sql():string{ |
|
27 | ||
28 | if(empty($this->from)){ |
|
29 | throw new QueryException('no FROM expression specified'); |
|
30 | } |
|
31 | ||
32 | # print_r([$this->cols, $this->from, $this->orderby, $this->groupby, $this->where]); |
|
33 | ||
34 | $glue = ','.PHP_EOL."\t"; |
|
35 | # var_dump($this->bindValues()); |
|
36 | ||
37 | $sql = 'SELECT '; |
|
38 | $sql .= $this->distinct ? 'DISTINCT ' : ''; |
|
39 | $sql .= !empty($this->cols) ? implode($glue , $this->cols).PHP_EOL : '* '; |
|
40 | $sql .= 'FROM '.implode($glue , $this->from); |
|
41 | $sql .= $this->_getWhere(); |
|
42 | $sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : ''; |
|
43 | $sql .= !empty($this->orderby) ? PHP_EOL.'ORDER BY '.implode($glue, $this->orderby) : ''; |
|
44 | $sql .= $this->limit ? PHP_EOL.'LIMIT '.($this->offset ? '?, ?' : '?') : ''; |
|
45 | ||
46 | return $sql; |
|
47 | } |
|
48 | ||
49 | } |
|
50 |
@@ 21-51 (lines=31) @@ | ||
18 | /** |
|
19 | * @link https://www.postgresql.org/docs/current/static/sql-select.html |
|
20 | */ |
|
21 | class Select extends SelectAbstract{ |
|
22 | ||
23 | /** |
|
24 | * @return string |
|
25 | * @throws \chillerlan\Database\Query\QueryException |
|
26 | */ |
|
27 | public function sql():string{ |
|
28 | ||
29 | if(empty($this->from)){ |
|
30 | throw new QueryException('no FROM expression specified'); |
|
31 | } |
|
32 | ||
33 | # print_r([$this->cols, $this->from, $this->orderby, $this->groupby, $this->where]); |
|
34 | ||
35 | $glue = ','.PHP_EOL."\t"; |
|
36 | ||
37 | $sql = 'SELECT '; |
|
38 | $sql .= $this->distinct ? 'DISTINCT ' : ''; |
|
39 | $sql .= !empty($this->cols) ? implode($glue , $this->cols).PHP_EOL : '* '; |
|
40 | $sql .= 'FROM '.implode($glue , $this->from); |
|
41 | $sql .= $this->_getWhere(); |
|
42 | $sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : ''; |
|
43 | $sql .= !empty($this->orderby) ? PHP_EOL.'ORDER BY '.implode($glue, $this->orderby) : ''; |
|
44 | $sql .= $this->offset ? PHP_EOL.'OFFSET ?' : ''; |
|
45 | $sql .= $this->limit ? PHP_EOL.'LIMIT ?' : ''; |
|
46 | ||
47 | return $sql; |
|
48 | } |
|
49 | ||
50 | ||
51 | } |
|
52 |
@@ 21-50 (lines=30) @@ | ||
18 | /** |
|
19 | * @link https://www.sqlite.org/lang_select.html |
|
20 | */ |
|
21 | class Select extends SelectAbstract{ |
|
22 | ||
23 | /** |
|
24 | * @return string |
|
25 | * @throws \chillerlan\Database\Query\QueryException |
|
26 | */ |
|
27 | public function sql():string{ |
|
28 | ||
29 | if(empty($this->from)){ |
|
30 | throw new QueryException('no FROM expression specified'); |
|
31 | } |
|
32 | ||
33 | # print_r([$this->cols, $this->from, $this->orderby, $this->groupby, $this->where]); |
|
34 | ||
35 | $glue = ','.PHP_EOL."\t"; |
|
36 | # var_dump($this->bindValues()); |
|
37 | ||
38 | $sql = 'SELECT '; |
|
39 | $sql .= $this->distinct ? 'DISTINCT ' : ''; |
|
40 | $sql .= !empty($this->cols) ? implode($glue , $this->cols).PHP_EOL : '* '; |
|
41 | $sql .= 'FROM '.implode($glue , $this->from); |
|
42 | $sql .= $this->_getWhere(); |
|
43 | $sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : ''; |
|
44 | $sql .= !empty($this->orderby) ? PHP_EOL.'ORDER BY '.implode($glue, $this->orderby) : ''; |
|
45 | $sql .= $this->limit ? PHP_EOL.'LIMIT '.($this->offset ? '?, ?' : '?') : ''; |
|
46 | ||
47 | return $sql; |
|
48 | } |
|
49 | ||
50 | } |
|
51 |