Hello,
My question is how can i get information out of a db. It seems an easy question but i can't get is to work. I have tried sql query's and some functions i got from the core api website but they al return the object. And not the information itself. if i do this SELECT aantal FROM mdl_test_module WHERE id='46'
The output is 'Resource id #27' how can i get the actual number that is stored in aantal?
Database acces
Number of replies: 3Re: Database acces
can nobody help me with this problem ?
Re: Database acces
Re: Database acces
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.
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.