Home  >  Article  >  Backend Development  >  PHP user query and judgment

PHP user query and judgment

墨辰丷
墨辰丷Original
2018-06-09 16:12:402398browse

This article mainly introduces PHP for user query and judgment. Interested friends can refer to it. I hope it will be helpful to everyone.

The example of this article describes the user query class implemented in PHP. The specific implementation method is as follows:

usertable` WHERE $field='$value'";
    $db=new database;
    $res=$db->execute($sql);
    $obj_user=mysql_fetch_object($res);
    return $obj_user;
   }
   else echo "查询方式不对";
  }
  function get_moreusers()
  {
   global $db;
   $argnums=func_num_args();
   $argarr=func_get_args();
   switch($argnums)
   {
    case 0:
     $sql="SELECT * FROM `$this->usertable`";
     break;
    case 2:
     $sql="SELECT * FROM `$this->usertable` WHERE $argarr[0]='$argarr[1]'";
     break;
    case 4:
     $sql="SELECT * FROM `$this->usertable` WHERE $argarr[0]='$argarr[1]' AND $argarr[2]='$argarr[3]'";
     break;
   }
   //$db=new database;
   $res=$this->execute($sql);
   $obj_arr=array();
   while($obj=mysql_fetch_object($res))
   {
    $obj_arr[]=$obj;
   }
   return $obj_arr;
  }
 }
?>

Summary: The above is the entire content of this article. I hope it can be useful for everyone’s learning. helped.

Related recommendations:

php method for recursive operations on files

php combined with session Methods of operating database

PHP method of accepting files and getting suffix names

The above is the detailed content of PHP user query and judgment. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn