I am new to moodle.I would like to fetch some values from the database.Please specify what are the files i needed and the functions.
Regards
Preetham
Hi Preetam
Although I can't help you as mysql is not my thing, I also doubt anyone can unless you give them a bit more information e.g. what information are you wanting to fetch?
Harry
Although I can't help you as mysql is not my thing, I also doubt anyone can unless you give them a bit more information e.g. what information are you wanting to fetch?
Harry
Hai smith
i want to fetch some value from one table.(any table).But i couldnt find out how they wrote code for this .Can you help me
regards
Preetham
i want to fetch some value from one table.(any table).But i couldnt find out how they wrote code for this .Can you help me
regards
Preetham
You can use the Moodle database functions from lib/datalib.php...
Example:
get_record('onetable','field',value);
will return the first record from a table where field = value.
Example:
get_record('onetable','field',value);
will return the first record from a table where field = value.
Hai jan
i tried like this
get_record('mdl_user','username',1);
where mdl_user is a table in moodle database
but it was not printing anything.
Can u help me i need it immdtly ... please
i tried like this
get_record('mdl_user','username',1);
where mdl_user is a table in moodle database
but it was not printing anything.
Can u help me i need it immdtly ... please
That's because '1' is an unlikely username. If you want to look up by userid, use something like get_record('mdl_user','id',1); or (better still) use some of the builtin functions for getting userdata.
Try experimenting with different functions. Use phpmyadmin to discover which fields are used in Moodle's database. It takes sometime to find out what different functions are for.
documentation: http://docs.moodle.org/en/Developer_documentation#Resources_and_tools
Try experimenting with different functions. Use phpmyadmin to discover which fields are used in Moodle's database. It takes sometime to find out what different functions are for.
documentation: http://docs.moodle.org/en/Developer_documentation#Resources_and_tools