classes/sql.php
/**
	 * Generates the WHERE/HAVING (condition) portion of the query.
	 *
	 * @param string $condition the SQL condition string
	 * @param array|string $values array of values for a IN() clause (or string operator)
	 * @return string
	 */
Generates the WHERE/HAVING (condition) portion of the query.
@param string $condition the SQL condition string
@param array|string $values array of values for a IN() clause (or string operator)
@return string
Generates the WHERE / HAVING ( condition ) portion of the query . @param string $condition the SQL condition string @param array|string $values array of values for a IN () clause ( or string operator ) @return string
public function condition($condition, $values = NULL)
	{
		$values = $values ? $values : '=';
		if(is_array($values))
		{
			foreach($values as $id => $value)
			{
				$values[$id] = $this->escape($value);
			}
			$values = '('.implode(',', $values).')';
			if(strpos($condition, ' ') === FALSE)
			{
				$condition = $this->quote_columns($condition). ' IN ';
			}
			$condition .= $values;
		}
		else
		{
			if(strpos($condition, ' ') === FALSE)
			{
				$condition = $this->quote_columns($condition). ' '. $values. ' ?';
			}
		}
		return '( '.$condition.' )';
	}
public function condition ( $ condition , $ values = NULL ) { $ values = $ values ? $ values : '=' ; if ( is_array ( $ values ) ) { foreach ( $ values as $ id => $ value ) { $ values [ $ id ] = $ this -> escape ( $ value ) ; } $ values = '(' . implode ( ',' , $ values ) . ')' ; if ( strpos ( $ condition , ' ' ) === FALSE ) { $ condition = $ this -> quote_columns ( $ condition ) . ' IN ' ; } $ condition .= $ values ; } else { if ( strpos ( $ condition , ' ' ) === FALSE ) { $ condition = $ this -> quote_columns ( $ condition ) . ' ' . $ values . ' ?' ; } } return '( ' . $ condition . ' )' ; }
Generates the WHERE/HAVING (condition) portion of the query.
Generates the WHERE / HAVING ( condition ) portion of the query .
/* Examples:
		SELECT ... FROM table...
			WHERE column = ?
			HAVING column > ?
			WHERE column IS NULL
			HAVING column IN (1, 2, 3)
			WHERE column NOT IN (1, 2, 3)
			HAVING column IN (SELECT column FROM t2)
			WHERE column IN (SELECT c3 FROM t2 WHERE c2 = table.column + 10)
			HAVING column BETWEEN ? AND ?
			WHERE column BETWEEN (SELECT c3 FROM t2 WHERE c2 = table.column + 10) AND ?
			HAVING EXISTS (SELECT column FROM t2 WHERE c2 > table.column)
		*/ // If no value is given, default to "equals" /*
		 * If an array of values is given then we are creating an IN/NOT IN
		 * clause. This is something that must be directly inserted into the
		 * query since prepared statements don't support one-to-many bound
		 * params yet.
		 */ // Escape each value and insert it into the SQL // Join values into a string // If no space it given - then add the IN clause // Add the value string // Allow condition('table.column') shorthand to mean "table.column = ?" // Compile the WHERE/HAVING clause and wrap in a grouping