Exemplo n.º 1
0
function spip_pg_cite($v, $t)
{
    if (is_null($v)) {
        return 'NULL';
    }
    // null php se traduit en NULL SQL
    if (sql_test_date($t)) {
        if ($v and strpos("0123456789", $v[0]) === false) {
            return spip_pg_frommysql($v);
        } else {
            if (strncmp($v, '0000', 4) == 0) {
                $v = "0001" . substr($v, 4);
            }
            if (strpos($v, "-00-00") === 4) {
                $v = substr($v, 0, 4) . "-01-01" . substr($v, 10);
            }
            return "timestamp '{$v}'";
        }
    } elseif (!sql_test_int($t)) {
        return "'" . pg_escape_string($v) . "'";
    } elseif (is_numeric($v) or strpos($v, 'CAST(') === 0) {
        return $v;
    } elseif ($v[0] == '0' and $v[1] !== 'x' and ctype_xdigit(substr($v, 1))) {
        return substr($v, 1);
    } else {
        spip_log("Warning: '{$v}'  n'est pas de type {$t}", 'pg.' . _LOG_AVERTISSEMENT);
        return intval($v);
    }
}
Exemplo n.º 2
0
Arquivo: pg.php Projeto: rhertzog/lcs
function spip_pg_cite($v, $t)
{
	if (sql_test_date($t)) {
		if ($v AND (strpos("0123456789", $v[0]) === false))
			return spip_pg_frommysql($v);
		else {
			if (strpos($v, "-00-00") <= 4) {
				$annee = substr($v,0,4);
				if (!intval($annee)) $annee = '0001';
				$v = $annee ."-01-01".substr($v,10);
			}
			return "timestamp '$v'";
		}
	}
	elseif (!sql_test_int($t))
		return   ("'" . addslashes($v) . "'");
	elseif (is_numeric($v) OR (strpos($v, 'CAST(') === 0))
		return $v;
	elseif ($v[0]== '0' AND $v[1]!=='x' AND  ctype_xdigit(substr($v,1)))
		return  substr($v,1);
	else {
		spip_log("Warning: '$v'  n'est pas de type $t", 'pg');
		return intval($v);
	}
}