From 866193490529d2ca2283839eb4b22b4cca09911e Mon Sep 17 00:00:00 2001 From: icewing Date: Wed, 28 May 2008 12:08:46 +0000 Subject: Marcus Povey * Fixed Where, WhereStatic and WhereSet git-svn-id: https://code.elgg.org/elgg/trunk@739 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/database.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'engine') diff --git a/engine/lib/database.php b/engine/lib/database.php index f18603d8c..13cd3053a 100644 --- a/engine/lib/database.php +++ b/engine/lib/database.php @@ -236,9 +236,14 @@ $this->right_field = sanitise_string($right_field); } + public function toStringNoLink() + { + return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->right_table}.{$this->right_field}"; + } + function __toString() { - return "{$this->link_operator} {$this->left_table }.{$this->left_field} {$this->operator} {$this->right_table}.{$this->right_field}"; + return "{$this->link_operator} " . $this->toStringNoLink(); } } @@ -269,12 +274,12 @@ if (is_numeric($value)) $this->value = (int)$value; else - $this->value = sanitise_string($value); + $this->value = "'".sanitise_string($value)."'"; } - function __toString() + public function toStringNoLink() { - return "{$this->link_operator} {$this->left_table }.{$this->left_field} {$this->operator} {$this->right_table}.{$this->right_field}"; + return "{$this->left_table }.{$this->left_field} {$this->operator} {$this->value}"; } } @@ -292,18 +297,19 @@ $this->wheres = $wheres; } - function __toString() + public function toStringNoLink() { $cnt = 0; - $string = "{$this->link_operator} ("; + $string = " ("; foreach ($this->wheres as $where) { if (!($where instanceof WhereQueryComponent)) throw new DatabaseException("Where set contains non WhereQueryComponent"); if (!$cnt) - $string .= "{$where->link_operator} "; - - $string .= " {$where->left_table }.{$where->left_field} {$where->operator} {$where->right_table}.{$where->right_field}"; + $string.= $where->toStringNoLink(); + else + $string.=" $where "; + $cnt ++; } $string .= ")"; -- cgit v1.2.3