Public feed #893387

Untitled

public text v1 · immutable
Raw Edit
·published 2008-02-06 02:12 UTC
rendered paste body
/**
	 * Adds an "in" condition to the where clause
	 * @param $field string Name of the column being examined
	 * @param $values mixed An array or string 
	 * 
 	 * @return Database
	 */
	public function in($field, $values) 
	{
		if (is_array($values))
		{
			$escaped_values = array();
			foreach ($values as $v)
			{
				if (is_numeric($v)) 
				{
					$escaped_values[] = $this->driver->escape_string($v);
				}
				else
				{
					$escaped_values[] = "'".$this->driver->escape_string($v)."'";
				}
			}
			$values = implode(",", $escaped_values);
		}
		$this->where($this->escape_column($field).' IN('.$values.')');
		
		return $this;
	}