Bart00
Posts: 8
|
Posted: 03/08/2010, 11:46 PM |
|
Today I tried to check if an array key exists:
$id = CCToSQL(CCGetFromGet('id'), ccsInteger);
if (array_key_exists($id, $testArray)) {
// do smth.
}
This code doesn't work, because array_key_exists expects either an int or a string, instead CCToSQL returns a float.
Can this be changed? Suggestion:
function CCToSQL($Value, $ValueType) {
if(!strlen($Value)) {
return "NULL";
}
else {
if($ValueType == ccsInteger) {
return intval($Value);
}
else if ($ValueType == ccsFloat) {
return doubleval(str_replace(",", ".", $Value));
}
else {
return "'" . str_replace("'", "''", $Value) . "'";
}
}
}
|