Example #1
0
function add_db_quotes($field, $value, $table = "", $type = null)
{
    global $strTableName;
    if ($table == "") {
        $table = $strTableName;
    }
    $pSet = new ProjectSettings($table);
    if ($type == null) {
        $type = $pSet->getFieldType($field);
    }
    if (IsBinaryType($type)) {
        return db_addslashesbinary($value);
    }
    if (($value === "" || $value === FALSE || is_null($value)) && !IsCharType($type)) {
        return "null";
    }
    if (NeedQuotes($type)) {
        if (!IsDateFieldType($type)) {
            $value = db_prepare_string($value);
        } else {
            $value = db_datequotes($value);
        }
    } else {
        $strvalue = (string) $value;
        $strvalue = str_replace(",", ".", $strvalue);
        if (is_numeric($strvalue)) {
            $value = $strvalue;
        } else {
            $value = 0;
        }
    }
    return $value;
}
Example #2
0
 function getWhereSql($groups)
 {
     $ret = '';
     $hasNull = $this->cutNull($groups, true);
     if (count($groups) > 0) {
         $lt = '';
         $gt = '';
         if ($this->_interval == 0) {
             $this->getLtGt($lt, $gt);
             $ret = '(' . cached_ffn($this->_name) . ' ' . $gt . ' ' . db_datequotes($groups[0]) . ' AND ' . cached_ffn($this->_name) . ' ' . $lt . ' ' . db_datequotes($groups[count($groups) - 1]) . ')';
         } else {
             if ($groups[0]['MIN'] <= $groups[count($groups) - 1]['MAX']) {
                 $ret = '(' . cached_ffn($this->_name) . ' >= ' . db_datequotes($groups[0]['MIN']) . ' AND ' . cached_ffn($this->_name) . ' <= ' . db_datequotes($groups[count($groups) - 1]['MAX']) . ')';
             } else {
                 $ret = '(' . cached_ffn($this->_name) . ' <= ' . db_datequotes($groups[0]['MAX']) . ' AND ' . cached_ffn($this->_name) . ' >= ' . db_datequotes($groups[count($groups) - 1]['MIN']) . ')';
             }
         }
     }
     if ($hasNull) {
         $ret .= ($ret ? ' OR ' : '') . cached_ffn($this->_name) . ' IS NULL ';
     }
     return $ret ? '(' . $ret . ')' : '';
 }
/**
 * @intellisense
 */
function add_db_quotes($field, $value, $table = "", $type = null)
{
	global $strTableName, $locale_info;
	if($table=="")
		$table=$strTableName;
	$pSet = new ProjectSettings($table);
	
	if($type == null)
		$type = $pSet->getFieldType($field);
	if(IsBinaryType($type))
		return db_addslashesbinary($value);
	if(($value==="" || $value===FALSE || is_null($value)) && !IsCharType($type))
		return "null";
	if(NeedQuotes($type))
	{
		if(!IsDateFieldType($type))
			$value=db_prepare_string($value);
		else
		{
			$y = "(\d\d\d\d)";
			$m = "(0?[1-9]|1[0-2])";
			$d = "(0?[1-9]|[1-2][0-9]|3[0-1])";
			$delim = "(-|".preg_quote($locale_info["LOCALE_SDATE"], "/").")";
			$reg = "/".$d.$delim.$m.$delim.$y."|".$m.$delim.$d.$delim.$y."|".$y.$delim.$m.$delim.$d."/";
			if( !preg_match($reg, $value, $matches) )
				return "null";

			$value=db_datequotes($value);
		}
	}
	else
	{
		$strvalue = (string)$value;
		if(is_numeric($strvalue))
			$value = str_replace(",",".",$strvalue);
		else
			$value=0;
	}
	return $value;
}
Example #4
0
 function PrepareValue($value, $type)
 {
     if (IsDateFieldType($type)) {
         return db_datequotes($value);
     }
     if (NeedQuotes($type)) {
         return db_prepare_string($value);
     } else {
         return 0 + $value;
     }
 }
function WRadd_db_quotes($field,$value,$table="")
{
	$type = WRGetFieldType($table.".".$field);
	if(IsBinaryType($type))
		return db_addslashesbinary($value);
	if(($value==="" || $value===FALSE) && !IsCharType($type))
		return "null";
	if(NeedQuotes($type))
	{
		if(!IsDateFieldType($type))
			$value=db_prepare_string($value);
		else
			$value=db_datequotes($value);
	}
	else
	{
		$strvalue = (string)$value;
		$strvalue = str_replace(",",".",$strvalue);
		if(is_numeric($strvalue))
			$value=$strvalue;
		else
			$value=0;
	}
	return $value;
}