1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Phuria SQL Builder package. |
5
|
|
|
* |
6
|
|
|
* Copyright (c) 2016 Beniamin Jonatan Šimko |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Phuria\SQLBuilder\QueryBuilder; |
13
|
|
|
|
14
|
|
|
use Phuria\SQLBuilder\Table\AbstractTable; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @author Beniamin Jonatan Šimko <[email protected]> |
18
|
|
|
*/ |
19
|
|
|
class DeleteBuilder extends AbstractBuilder implements |
20
|
|
|
Clause\LimitClauseInterface, |
21
|
|
|
Clause\OrderByClauseInterface, |
22
|
|
|
Clause\WhereClauseInterface, |
23
|
|
|
Component\JoinComponentInterface, |
24
|
|
|
Component\TableComponentInterface |
25
|
|
|
{ |
26
|
|
|
use Clause\LimitClauseTrait; |
27
|
|
|
use Clause\OrderByClauseTrait; |
28
|
|
|
use Clause\WhereClauseTrait; |
29
|
|
|
use Component\JoinComponentTrait; |
30
|
|
|
use Component\ParameterComponentTrait; |
31
|
|
|
use Component\TableComponentTrait; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @var array $deleteClauses |
35
|
|
|
*/ |
36
|
|
|
private $deleteClauses = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return $this |
40
|
|
|
*/ |
41
|
1 |
|
public function addDelete() |
42
|
|
|
{ |
43
|
1 |
|
foreach (func_get_args() as $clause) { |
44
|
1 |
|
$this->doAddDelete($clause); |
45
|
1 |
|
} |
46
|
|
|
|
47
|
1 |
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @param mixed $clause |
52
|
|
|
*/ |
53
|
1 |
|
private function doAddDelete($clause) |
54
|
|
|
{ |
55
|
1 |
|
$this->deleteClauses[] = $clause; |
56
|
1 |
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return array |
60
|
|
|
*/ |
61
|
3 |
|
public function getDeleteClauses() |
62
|
|
|
{ |
63
|
3 |
|
return $this->deleteClauses; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param mixed $table |
68
|
|
|
* @param string $alias |
|
|
|
|
69
|
|
|
* |
70
|
|
|
* @return AbstractTable |
71
|
|
|
*/ |
72
|
3 |
|
public function from($table, $alias = null) |
73
|
|
|
{ |
74
|
3 |
|
return $this->addFrom($table, $alias); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param mixed $table |
79
|
|
|
* @param string $alias |
|
|
|
|
80
|
|
|
* |
81
|
|
|
* @return AbstractTable |
82
|
|
|
*/ |
83
|
3 |
|
public function addFrom($table, $alias = null) |
84
|
|
|
{ |
85
|
3 |
|
return $this->addRootTable($table, $alias); |
86
|
|
|
} |
87
|
|
|
} |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.