Databases: database retrievel

Databases: database retrievel

โดย preetam thakur -
Number of replies: 5
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
การประเมินโดยเฉลี่ย: -
In reply to preetam thakur

Re: Databases: database retrievel

โดย Just H -
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
การประเมินโดยเฉลี่ย: -
In reply to Just H

Re: Databases: database retrievel

โดย vijesh g -
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
การประเมินโดยเฉลี่ย: -
In reply to vijesh g

Re: Databases: database retrievel

โดย Jan Dierckx -
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.
การประเมินโดยเฉลี่ย: -
In reply to Jan Dierckx

Pblm again -please help-database retrievel

โดย vijesh g -
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
การประเมินโดยเฉลี่ย: -
In reply to vijesh g

Re: Pblm again -please help-database retrievel

โดย Jan Dierckx -
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

การประเมินโดยเฉลี่ย: -