Destoon the system automatically connects the database after the system is initialized and saves the database operations object to $DB. For database operation methods please refer to the Include/db_mysql.class.php function prototype, the following examples of common database operations.
1. Execute SQL statement
$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 more information
$A = Array ();
$result = $db->query ("select * from ' {$DT _pre}table ' WHERE ' xxx ' = ' yyy ' ORDER by ' zzz ' DESC LIMIT 0,10");
while ($r = $db->fetch_array ($result)) {
$A [] = $r;
}
Print_r ($A);
3. Read a single message
$A = $db->get_one ("select * from ' {$DT _pre}table ' WHERE ' xxx ' = ' yyy '");
Print_r ($A);
4, the total number of calculations
$A = $db->get_one ("Select COUNT (*) as num from ' {$DT _pre}table ' WHERE ' xxx ' = ' yyy '");
echo $A [' num '];
The system's table prefixes can be used in variable $dt_pre (commonly used in statements) or $db->pre (commonly used in functions).
If you use database operations in a function, you need to first perform a global $db;