User query instances implemented by php. Php user query instance this article describes the user query class implemented by php. Share it with you for your reference. The specific implementation method is as follows :? 1234567891011121314 php user query instance
This example describes the user query class implemented by php. Share it with you for your reference. The specific implementation method is as follows:
?
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45 |
Class user
{
Var $ usertable;
Function get_oneuser ($ field, $ value)
{
$ Field_array = array ("id", "name"); // query method
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 incorrect ";
}
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 php programming.
Examples in this article describes the user query class implemented by php. Share it with you for your reference. The specific implementation method is as follows :? 1 2 3 4 5 6 7 8 9 10 11 12 13 14...