This example describes the user query class for PHP implementations. Share to everyone for your reference. The implementation method is as follows:
<?php class User {var $usertable; function Get_oneuser ($field, $value) {$field _array=array ("id", "name");
Query mode if (In_array ($field, $field _array)) {$sql = "select * from ' $this->usertable ' WHERE $field = ' $value '";
$DB =new database;
$res = $db->execute ($sql);
$obj _user=mysql_fetch_object ($res);
return $obj _user;
else echo "Query method is wrong";
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; }
}?>
I hope this article will help you with your PHP programming.