Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Developer FAQ: diferència entre les revisions

De MoodleDocs
Salta a:navegació, cerca
Cap resum de modificació
Cap resum de modificació
Línia 3: Línia 3:
===Where can I see a schema for the structure of the Moodle database?===
===Where can I see a schema for the structure of the Moodle database?===


When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the [[Coding#Database_structures coding guidelines for database structure]] give an outline of the general approach.
When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the [[Coding#Database_structures | coding guidelines for database structure]] give an outline of the general approach.




Línia 18: Línia 18:
===How do I insert/retrieve records in the database, without creating my own database connections?===
===How do I insert/retrieve records in the database, without creating my own database connections?===


Always use the "datalib" functions, such as insert_record() or get_record(). Look at [http://moodle.sourceforge.net/dhawes-phpdoc/moodlecore/_lib_datalib_php.html the documentation for datalib.php] for more functions and details of use.
Always use the "datalib" functions, such as insert_record() or get_record(). This helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.
 
Look at [http://moodle.sourceforge.net/dhawes-phpdoc/moodlecore/_lib_datalib_php.html the documentation for datalib.php] for the list of functions and details of use.


===How do I get/set configuration settings?===
===How do I get/set configuration settings?===


...
...

Revisió del 11:08, 5 abr 2006

Moodle's database

Where can I see a schema for the structure of the Moodle database?

When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the coding guidelines for database structure give an outline of the general approach.


How to get/set information when writing new Moodle code

How do I find out the currently-logged-on user?

The global object $USER, which contains the numeric $USER->id among other things.

How do I find out the current course?

...

How do I insert/retrieve records in the database, without creating my own database connections?

Always use the "datalib" functions, such as insert_record() or get_record(). This helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.

Look at the documentation for datalib.php for the list of functions and details of use.

How do I get/set configuration settings?

...