|
This book isn't about database programming, but if you are familiar with that concept, I want you to know how PHP-Nuke makes databases accessible. If these terms and concepts are meaningless to you, just skip ahead to the next topic. To query one or more rows from the PHP-Nuke database, use something like this:
The variable, $result, contains the queried rows. To get them out, use something like this: While list($field1, $field2) = $db->sql_fetchrow($result) { /* code here */ } $field1 contains the first column's data; $field2 contains the second column's data. This construct repeats once for each row of data that $result contains. You can see how many rows that is by executing this: $numrows = $db->sql_numrows($result) The $db object variable is defined by PHP-Nuke and is available in all modules. You will, however, need to explicitly declare it within each function of a module: Global $db
|
|