sqlfuns.php

来自「酒店管理系统」· PHP 代码 · 共 38 行

PHP
38
字号
<?

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . htmlspecialchars($theValue) . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != ""||$theValue==0) ? 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 findindb($conn,$files,$table,$value,$valuetype)
{
$sqlquery=sprintf("select %s from %s where %s=%s",$files,$table, $files,GetSQLValueString($value, $valuetype));
  $LoginRS=odbc_exec($conn,$sqlquery); 
  $loginFoundUser = 0;
while(odbc_fetch_row($LoginRS))
 $loginFoundUser+=1;
 return $loginFoundUser;
}


?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?