After the system is initialized, the system automatically connects to the database and saves the database operation object in $ dB. For database operation methods, see the include/db_mysql.class.php function prototype. The following is only an example of common operations.
1. Execute SQL statements
$ Db-> query ("insert into '{$ dt_pre} table' ('xxx') values ('yyy ')");
$ Db-> query ("Update' {$ dt_pre} table 'set 'xxx' = 'yyy' where 'zzz' = 1 ");
$ Db-> query ("delete from '{$ dt_pre} table 'where 'zzz' = 1 ");
2. read multiple messages
$ A = array ();
$ Result = $ db-> query ("select * from '{$ dt_pre} table 'where 'xxx' = 'yyy' order by 'zzz' DESC limit ");
While ($ r = $ db-> fetch_array ($ result )){
$ A [] = $ R;
}
Print_r ($ );
3. Read a single message
$ A = $ db-> get_one ("select * from '{$ dt_pre} table 'where 'xxx' = 'yyy '");
Print_r ($ );
4. Total number of computations
$ A = $ db-> get_one ("select count (*) as num from '{$ dt_pre} table 'where 'xxx' = 'yyy '");
Echo $ A ['num'];
The system table prefix can use the variable $ dt_pre (usually used in statements) or $ db-> pre (usually used in functions ).
If you use database operations in a function, you must first perform global $ dB;