openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

README.md (641B)


      1 # Database module
      2 
      3 This module contains database specific functionality.
      4 
      5 ## Usage
      6 
      7 ### Initialisation
      8 
      9 ```
     10 $database = new Database( [
     11                  'dsn'     =>'mysql:host=localhost; dbname=name; charset=utf8',
     12                  'user'    =>'user','
     13                  'password'=>'...'
     14             ] );
     15 ```
     16 
     17 The `dsn` is described in the [PDO manual](https://www.php.net/manual/de/pdo.construct.php).
     18 
     19 ## Executing queries
     20 The database object is able to create Statement objects. You only have to apply a SQL query.
     21 ```
     22 $statement = $database->sql('select * from table');
     23 
     24 $data = $statement->getRow();
     25 $data = $data['column'];
     26 // ...
     27 ```