-
Book Overview & Buying
-
Table Of Contents
Moodle 1.9 Extension Development
When developing your database code, there are some best practices that you should adhere to. We will briefly discuss some of these.
When extracting a large record from a data table, consider what information you actually need. Then, only get the field or fields that you need for processing. If it is one field you need, from one record, always use a get_field call. If you need more than one field, specify the ones you need in your get_record() call. Make sure that you include the id field as the first field if you are retrieving more than one record, so that there is a unique index for the returned array.
By retrieving only the data that you need, you can improve the speed of the database function and reduce the amount of memory needed for the program.
When your code expects multiple records from a database call, it is always best to limit the number of records that you will get back. Use the $limitfrom and $limitnum...
Change the font size
Change margin width
Change background colour