Database acces

Re: Database acces

by Brian King -
Number of replies: 0
It sounds like you're using mysql functions in php to query the database? See http://faq.php-q.net/#resource.

But if you're just accessing the moodle database, it's better to use the functions provided by moodle for that. See the file lib/datalib.php.

For example, you could use:
get_record_select("test_module", "id = 46", "aantal") or get_records_select("test_module", "id = 46", "id", "aantal")
depending on whether you're expecting one or one+ records from the query.

Note that the table prefix 'mdl_' is added by the moodle database functions, so you should omit it.
Average of ratings: Useful (1)