PHP 判断字符类型,并转换返回
2007-10-27 14:36
597 查看
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
function GetSQLValueStringForSelect($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? '"%' . $theValue . '%"' : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
作者应该是Flex Builder3.0的作者,来自自动生成的代码段
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
function GetSQLValueStringForSelect($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? '"%' . $theValue . '%"' : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? '"' . doubleval($theValue) . '"' : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? '"' . $theValue . '"' : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
作者应该是Flex Builder3.0的作者,来自自动生成的代码段
相关文章推荐
- PHP 中的类型强制转换 字符转数值
- 从C/C++迁移到PHP——判断字符类型的函数
- PHP数据类型转换(字符转数字,数字转字符)
- PHP数据类型转换(字符转数字,数字转字符)
- window对象的弹窗方法、将字符转换为数据、判断变量类型
- PHP数据类型转换(字符转数字,数字转字符)
- PHP数据类型转换(字符转数字,数字转字符)
- php数据类型的判断及转换
- PHP数据类型转换(字符转数字,数字转字符)
- PHP数据类型转换(字符转数字,数字转字符)
- php 字符安全转码为UTF-8 的函数,转换前做判断
- PHP数据类型转换(字符转数字,数字转字符)
- 判断字符类型及转换类型的函数
- 从C/C++迁移到PHP——判断字符类型的函数
- PHP数据类型转换(字符转数字,数字转字符)
- PHP数据类型转换(字符转数字,数字转字符)
- php常见数据类型转换与判断
- PHP数据类型转换(字符转数字,数字转字符)
- php判断输入字符类型
- 利用转换表判断字符的类型(练习)