aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/WhereStaticQueryComponent.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/WhereStaticQueryComponent.php')
-rw-r--r--engine/classes/WhereStaticQueryComponent.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/engine/classes/WhereStaticQueryComponent.php b/engine/classes/WhereStaticQueryComponent.php
new file mode 100644
index 000000000..ddc036fd1
--- /dev/null
+++ b/engine/classes/WhereStaticQueryComponent.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * @class WhereStaticQueryComponent
+ * A component of a where query where there is no right hand table, rather a static value.
+ * @author Curverider Ltd
+ * @see Query
+ */
+class WhereStaticQueryComponent extends WhereQueryComponent
+{
+ /**
+ * A where query.
+ *
+ * @param string $left_table The table on the left of the operator
+ * @param string $left_field The left field
+ * @param string $operator The operator eg "=" or "<"
+ * @param string $value The value
+ * @param string $link_operator How this where clause links with the previous clause, eg. "and" "or"
+ */
+ function __construct($left_table, $left_field, $operator, $value, $link_operator = "and")
+ {
+ global $CONFIG;
+
+ $this->link_operator = sanitise_string($link_operator);
+ $this->left_table = $CONFIG->dbprefix . sanitise_string($left_table);
+ $this->left_field = sanitise_string($left_field);
+ $this->operator = sanitise_string($operator);
+ if (is_numeric($value))
+ $this->value = (int)$value;
+ else
+ $this->value = "'".sanitise_string($value)."'";
+ }
+
+ /**
+ * Return the SQL without the link operator.
+ */
+ public function toStringNoLink()
+ {
+ return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->value}";
+ }
+}