Esempio n. 1
0
	/**
	 * Allow for grouping of groups of where clauses.
	 *
	 * This is useful for statements such as
	 * WHERE (this = 1 OR that = 1) AND something = blah;
	 *
	 * The where clause can either be a single array, a single string, or a list of arguments
	 *
	 * @param string $separator 'AND', 'OR'
	 * @param array|string $wheres
	 * @return Dataset
	 */
	public function whereGroup($separator, $wheres){
		$args = func_get_args();

		// Because the first argument is the 'AND' or 'OR' string.
		$sep = array_shift($args);
		$clause = new DatasetWhereClause();
		$clause->setSeparator($sep);
		$clause->addWhere($args);

		// Since everything will be under the root node anyway...
		$this->getWhereClause()->addWhere($clause);

		// Allow chaining
		return $this;
	}
	/**
	 * Shortcut function to add a subgroup to an existing group.
	 *
	 * @param $sep
	 * @param $arguments
	 */
	public function addWhereSub($sep, $arguments){
		$subgroup = new DatasetWhereClause();
		$subgroup->setSeparator($sep);
		$subgroup->addWhere($arguments);

		$this->addWhere($subgroup);
	}