Ocs-server/Gfx4/Database: Difference between revisions

From KDE Community Wiki
(Created page with "In Gfx there's the static class EDatabase which, if enabled, loads at the start of the script. It makes uses of a configuration file called ''database.conf.php'' that must con...")
(No difference)

Revision as of 13:37, 28 July 2015

In Gfx there's the static class EDatabase which, if enabled, loads at the start of the script. It makes uses of a configuration file called database.conf.php that must contain correct values of a MySQL database. Works on more db drivers is in the roadmap.

Small reference:

  • EDatabase::q($sql_query) -> execute $sql_query
  • EDatabase::sq($sql_query) -> execute $sql_query and returns the first result. Useful for counts etc.
  • EDatabase::table_exists($table) -> check if table exists and return boolean.
  • EDatabase::last_insert_id() -> returns the id of the last inserted row.

Database functionalities can be enabled/disabled in the generic config file ("config/generic.conf.php"): Example:

<?php die("You cannot see config in here."); ?>
database|yes
database|no

database.conf.php

Example of a valid configuration file:

<?php die(); ?>
name|test
host|localhost
user|root
password|asd