1: <?php
2:
3: namespace Alchemy\core\query;
4: use Alchemy\core\Element;
5:
6:
7: /**
8: * Represent a JOIN clause
9: */
10: class Join extends Element implements IQueryFragment {
11: const LEFT = 'LEFT';
12: const RIGHT = 'RIGHT';
13: const FULL = 'FULL';
14: const INNER = 'INNER';
15: const OUTER = 'OUTER';
16:
17: protected $direction;
18: protected $type;
19: protected $table;
20: protected $on;
21:
22:
23: /**
24: * Object constructor
25: *
26: * @param string $direction Join::LEFT or Join::RIGHT
27: * @param string $type Join::FULL, Join::INNER, or Join::OUTER
28: * @param Table $table
29: * @param Expression $on
30: */
31: public function __construct($direction, $type, TableRef $table, Expression $on = null) {
32: $this->direction = $direction;
33: $this->type = $type;
34: $this->table = &$table;
35: $this->on = &$on;
36: $this->addTag("sql.compile", "Join");
37: }
38:
39:
40: /**
41: * @return string
42: */
43: public function getDirection() {
44: return $this->direction;
45: }
46:
47:
48: /**
49: * @return Expression
50: */
51: public function getOn() {
52: return $this->on;
53: }
54:
55:
56: /**
57: * Recursively get all scalar parameters used by this clause
58: * in the order which they are used in the expression
59: *
60: * @return array(Scalar, Scalar, ...)
61: */
62: public function parameters() {
63: return $this->on->parameters();
64: }
65:
66:
67: /**
68: * @return Table
69: */
70: public function getTable() {
71: return $this->table;
72: }
73:
74:
75: /**
76: * @return string
77: */
78: public function getType() {
79: return $this->type;
80: }
81: }
82: