1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
16:
17: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
18:
19: 20: 21: 22: 23: 24:
25: class cGenericDbDriverMysql extends cGenericDbDriver {
26:
27: 28: 29: 30: 31: 32: 33: 34: 35:
36: public function buildJoinQuery($destinationTable, $destinationClass, $destinationPrimaryKey, $sourceClass, $primaryKey) {
37:
38: $field = "$destinationClass.$destinationPrimaryKey";
39: $tables = "";
40: $join = "LEFT JOIN $destinationTable AS $destinationClass ON " . cSecurity::toString($sourceClass . "." . $primaryKey) . " = " . cSecurity::toString($destinationClass . "." . $primaryKey);
41: $where = "";
42:
43: return array(
44: "field" => $field,
45: "table" => $tables,
46: "join" => $join,
47: "where" => $where
48: );
49: }
50:
51: 52: 53: 54: 55: 56: 57:
58: public function buildOperator($sField, $sOperator, $sRestriction) {
59: $sOperator = strtolower($sOperator);
60:
61: $sWhereStatement = "";
62:
63: switch ($sOperator) {
64: case "matchbool":
65: $sqlStatement = "MATCH (%s) AGAINST ('%s' IN BOOLEAN MODE)";
66: $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
67: break;
68: case "match":
69: $sqlStatement = "MATCH (%s) AGAINST ('%s')";
70: $sWhereStatement = sprintf($sqlStatement, $sField, $this->_oItemClassInstance->_inFilter($sRestriction));
71: break;
72: case "like":
73: $sqlStatement = "%s LIKE '%%%s%%'";
74: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
75: break;
76: case "likeleft":
77: $sqlStatement = "%s LIKE '%s%%'";
78: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
79: break;
80: case "likeright":
81: $sqlStatement = "%s LIKE '%%%s'";
82: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
83: break;
84: case "notlike":
85: $sqlStatement = "%s NOT LIKE '%%%s%%'";
86: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
87: break;
88: case "notlikeleft":
89: $sqlStatement = "%s NOT LIKE '%s%%'";
90: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
91: break;
92: case "notlikeright":
93: $sqlStatement = "%s NOT LIKE '%%%s'";
94: $sWhereStatement = sprintf($sqlStatement, cSecurity::toString($sField), $this->_oItemClassInstance->_inFilter($sRestriction));
95: break;
96: case "fulltext":
97:
98: break;
99: case "in":
100: if (is_array($sRestriction)) {
101: $items = array();
102:
103: foreach ($sRestriction as $key => $sRestrictionItem) {
104: $items[] = "'" . $this->_oItemClassInstance->_inFilter($sRestrictionItem) . "'";
105: }
106:
107: $sRestriction = implode(", ", $items);
108: } else {
109: $sRestriction = "'" . $sRestriction . "'";
110: }
111:
112: $sWhereStatement = implode(" ", array(
113: $sField,
114: "IN (",
115: $sRestriction,
116: ")"
117: ));
118: break;
119: default:
120: $sRestriction = "'" . $this->_oItemClassInstance->_inFilter($sRestriction) . "'";
121:
122: $sWhereStatement = implode(" ", array(
123: $sField,
124: $sOperator,
125: $sRestriction
126: ));
127: }
128:
129: return $sWhereStatement;
130: }
131: }
132: