 |
 | |
| | | | |
|  |
 |
 |
|
|
|
The Complete Idiots Guide to Nuke v.3.2 |
|
|
|
|
Database Integration
Database integration is really quite simple. There are three globals that apply to Databases in Nuke. These are: $db, $prefix and $user_prefix.
When initiating a database query, you use the $db global, followed by the query type, then the query.
The query types are as follows:
| sql_query | Normal SQL query for Selects, Inserts, Updates, Detetes and any table / database structure changes |
sql_numrows | counts the number of rows returned by the query |
sql_fetchrow | Creates an array of values that the query returned |
So, a typical database query might look as follows:
$sql = "SELECT * FROM ".$prefix."_random_table WHERE id=1";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
|
Now, the reason why we put ".$prefix." in there instead of nuke is because not everybody uses the nuke prefix on their databases, so by putting ".$prefix." the prefix that the site has on the config.php file will be called.
Sometimes, $prefix will be replaced with $user_prefix if the query is being targeted at the users table of the database. This is because some sites share a database but use different prefixes to keep the sites information seperate, but in these cases, it is also common for these sites to share a user table to save people having to register twice on the sites.
|
|
|
|
|
|
Last Updated: July 6th 2003 |
|
|
|