1: <?php
2:
3: 4: 5:
6: class QPgConditionILike extends QQConditionComparison {
7: 8: 9: 10: 11: 12: 13: 14:
15: public function __construct(QQColumnNode $objQueryNode, $strValue) {
16: parent::__construct($objQueryNode);
17:
18: if ($strValue instanceof QQNamedValue) {
19: $this->mixOperand = $strValue;
20: } else {
21: try {
22: $this->mixOperand = QType::Cast($strValue, QType::String);
23: } catch (QCallerException $objExc) {
24: $objExc->IncrementOffset();
25: $objExc->IncrementOffset();
26: throw $objExc;
27: }
28: }
29: }
30:
31: 32: 33:
34: public function UpdateQueryBuilder(QQueryBuilder $objBuilder) {
35: $mixOperand = $this->mixOperand;
36: if ($mixOperand instanceof QQNamedValue) {
37:
38: $objBuilder->AddWhereItem($this->objQueryNode->GetColumnAlias($objBuilder) . ' ILIKE ' . $mixOperand->Parameter());
39: } else {
40: $objBuilder->AddWhereItem($this->objQueryNode->GetColumnAlias($objBuilder) . ' ILIKE ' . $objBuilder->Database->SqlVariable($mixOperand));
41: }
42: }
43: }
44:
45: 46: 47: 48:
49: class QPgConditionJsonContains extends QQConditionComparison {
50: 51: 52: 53: 54: 55: 56: 57:
58: public function __construct(QQColumnNode $objQueryNode, $strValue) {
59: parent::__construct($objQueryNode);
60:
61: if ($strValue instanceof QQNamedValue) {
62: $this->mixOperand = $strValue;
63: } else {
64: try {
65: $this->mixOperand = QType::Cast($strValue, QType::String);
66: } catch (QCallerException $objExc) {
67: $objExc->IncrementOffset();
68: $objExc->IncrementOffset();
69: throw $objExc;
70: }
71: }
72: }
73:
74: 75: 76:
77: public function UpdateQueryBuilder(QQueryBuilder $objBuilder) {
78: $mixOperand = $this->mixOperand;
79: if ($mixOperand instanceof QQNamedValue) {
80:
81: $objBuilder->AddWhereItem($this->objQueryNode->GetColumnAlias($objBuilder) . ' @> ' . $mixOperand->Parameter());
82: } else {
83: $objBuilder->AddWhereItem($this->objQueryNode->GetColumnAlias($objBuilder) . ' @> ' . $objBuilder->Database->SqlVariable($mixOperand));
84: }
85: }
86: }
87:
88:
89: 90: 91:
92: class QPgQ extends QQ {
93: 94: 95: 96: 97: 98: 99: 100:
101: static public function ILike(QQColumnNode $objQueryNode, $strValue) {
102: return new QPgConditionILike($objQueryNode, $strValue);
103: }
104:
105: 106: 107: 108: 109: 110: 111: 112:
113: static public function JsonContains(QQColumnNode $objQueryNode, $strValue) {
114: return new QPgConditionJsonContains($objQueryNode, $strValue);
115: }
116: }