Completed
Push — master ( ead087...20edd5 )
by smiley
02:40
created

Select::sql()   C

Complexity

Conditions 8
Paths 65

Size

Total Lines 26
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 26
rs 5.3846
c 0
b 0
f 0
cc 8
eloc 15
nc 65
nop 0
1
<?php
2
/**
3
 * Class Select
4
 *
5
 * @filesource   Select.php
6
 * @created      03.06.2017
7
 * @package      chillerlan\Database\Query\Dialects\Firebird
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2017 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\Database\Query\Dialects\Firebird;
14
15
use chillerlan\Database\Query\QueryException;
16
use chillerlan\Database\Query\SelectAbstract;
17
18
/**
19
 * @link https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-dml-select.html
20
 */
21
class Select extends SelectAbstract{
22
	use FirebirdBindValuesTrait;
23
24
	/**
25
	 * @return string
26
	 * @throws \chillerlan\Database\Query\QueryException
27
	 */
28
	public function sql():string{
29
30
		if(empty($this->from)){
31
			throw new QueryException('no FROM expression specified');
32
		}
33
34
#		print_r([$this->cols, $this->from, $this->orderby, $this->groupby, $this->where]);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
36
		$glue = ','.PHP_EOL."\t";
37
#		var_dump($this->bindValues());
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
39
		if(is_null($this->offset)){
40
			$this->offset = 0;
41
		}
42
43
		$sql  = 'SELECT ';
44
		$sql .= $this->limit ? 'FIRST ? SKIP ? ' : '';
45
		$sql .= $this->distinct ? 'DISTINCT ' : '';
46
		$sql .= !empty($this->cols) ? implode($glue , $this->cols).PHP_EOL : '* ';
47
		$sql .= 'FROM '.implode($glue , $this->from);
48
		$sql .= $this->_getWhere();
49
		$sql .= !empty($this->groupby) ? PHP_EOL.'GROUP BY '.implode($glue, $this->groupby) : '';
50
		$sql .= !empty($this->orderby) ? PHP_EOL.'ORDER BY '.implode($glue, $this->orderby) : '';
51
52
		return $sql;
53
	}
54
55
56
}
57