Welcome Guest, Not a member yet? Register   Sign In
Active Record Class - MORE SUPPORT
#3

[eluser]Cong Do[/eluser]
Dam should have read this a bit earlyer.
where not, is already inplemented as where("key !=","val").

I just made my own ones, the difference is that you don't need to use where_in, where_in_or, where_not_in or where_not_in_or.

But just where and whereor Big Grin.

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(is_array($v))
{
if ( ! $this->_has_operator($k))
{
$k .= ' IN';
}

foreach($v as $kx=>$vx)
{
$v[$kx] = ' '.$this->escape($vx);
}
$v= ' ('.implode(', ',$v).') ';
}
else
{
if ( ! $this->_has_operator($k))
{
$k .= ' =';
}
$v = ' '.$this->escape($v);
}
}

$this->ar_where[] = $prefix.$k.$v;
}
return $this;
}

function _has_operator($str)
{
$str = trim($str);
if ( ! preg_match("/(\s|<|>|!|=|is null|is not null|in|not in)/i", $str))
{
return FALSE;
}

return TRUE;
}

Regards,
Cong Do


Messages In This Thread
Active Record Class - MORE SUPPORT - by El Forum - 01-09-2008, 08:06 PM
Active Record Class - MORE SUPPORT - by El Forum - 01-09-2008, 09:05 PM
Active Record Class - MORE SUPPORT - by El Forum - 01-09-2008, 10:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB