All pastes #489916 Raw Edit

Someone

public text v1 · immutable
·published 2007-05-15 19:25 UTC
rendered paste body
function _where($key, $value = NULL, $type = 'AND ')
	{
		if ( ! is_array($key))
		{
			$key = array($key => $value);
		}
 	 	
		foreach ($key as $k => $v)
		{
			$prefix = (count($this->ar_where) == 0) ? '' : $type;
			
			if ( ! is_null($v))
			{
				if ( ! $this->_has_operator($k))
				{
					$k .= ' =';
				}
			
				$v = ' '.$this->escape($v);
			}
			else
				$v = " = NULL";
						
			$this->ar_where[] = $prefix.$k.$v;
		}
		return $this;
	}

// Controller
function test()
	{
		$somearray = array
		(
		    0 => 3,
		    1 => null,
		    2 => null
		);
		
		$this->db->from('test')->where($somearray);
		$query = $this->db->get();
		echo $this->db->last_query();
		
	}