private function buildWhere()
	{
		$strings = [];
		$first   = true;
		$depth   = 0;

		foreach ($this->where as $constraint)
		{
			$string = '';

			if (array_key_exists('resetdepth', $constraint))
			{
				$string .= str_repeat(')', ($depth - $constraint['depth']));
			}
			else
			{
				$string .= ($constraint['depth'] < $depth) ? ') ' : '';
				$string .= ($first) ? 'WHERE ' : strtoupper($constraint['logical']) . ' ';
				$string .= ($constraint['depth'] > $depth) ? '(' : '';

				// Make sure this isn't a 'raw' where clause
				if (array_key_exists('raw', $constraint))
				{
					$string .= $constraint['raw'];

					foreach ($constraint['bindings'] as $binding)
					{
						$this->bind($binding);
					}
				}
				else
				{
					$string .= $this->connection->quoteName($constraint['column']);
					$string .= ' ' . $constraint['operator'];
					if (is_array($constraint['value']))
					{
						$values = array();
						foreach ($constraint['value'] as $value)
						{
							$values[] = '?';
							$this->bind($value);
						}
						$string .= ' (' . ((!empty($values)) ? implode(',', $values) : "''") . ')';
					}
					else
					{
						$string .= ' ?';
						$this->bind($constraint['value']);
					}
				}
			}

			$strings[] = $string;
			$first     = false;
			$depth     = $constraint['depth'];
		}

		// Catch instance where last item was at a greater depth and never got a closing ')'
		if ($depth > 0)
		{
			$strings[] = str_repeat(')', $depth);
		}

		return implode("\n", $strings);
	}