Ocs-server/Gfx4/Database

From KDE Community Wiki
Revision as of 13:21, 20 May 2016 by Snizzo (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

In Gfx database is abstracted using the multipurpose class EModel which queries the correct database driver. More database drivers are coming, though. Mysql driver is fully functional, sqlite driver is work in progress.

Small reference:

  • EMysql::q($sql_query) -> execute $sql_query
  • EMysql::sq($sql_query) -> execute $sql_query and returns the first result. Useful for counts etc.
  • EMysql::table_exists($table) -> check if table exists and return boolean.
  • EMysql::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
databasedriver|EMysql

databasedriver can also be ESQLite, but support for SQLite database is still not complete. To use the correct database abstraction please use EModel class (standalone o subclassed).


database.conf.php

Example of a valid configuration file:

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