DatabaseService  (since version 2.0)
Type Service
Constants
string PROFILE_PREFIX = " DS. "
The profile prefix which is added to the profile name.
Description
The database service handles the connection of the available DAOs

The created profiles are only created and connected when the first call is made. As long as the DAO of the profile is not called it just remains in the data container

Currently available DAOs:
PDOMySQLDAO


This service uses the ProfileService to handle als created profiles.
Examples
<?php

// create database object
DatabaseService::CreateProfile
(
    
'SampleDatabase',
    array
    (
    
'driver'    => 'mysql',
    
'hostname'    => 'localhost',
    
'database'    => 'brickoo',
    
'username'    => 'root',
    
'password'    => '',
    
'DAO'        => 'PDOMySQLDAO'
    
)
);

// use the created profile
DatabaseService::Begin('SampleDatabase');


// get the current DAO object (PHP < 5.3)
$DAO DatabaseService::GetDAO();

// with PHP >= 5.3 you dont need to retrieve the DAO object by yourself
// example:
// DatabaseService::fetchAll('SELECT * FROM  User');

// retrieve all database data with limit of 10 and age > 30
$content $DAO->fetchAll
(
    
'SELECT * FROM User WHERE age > ? ORDER BY age DESC LIMIT 10',
    array(
30),
    
PDOMySQLDAO::CALCULATE_MAX_ROWS
);

var_export('User rows : ' .$content);
var_export('Available rows : ' $content['found_rows']);

?>

Last change 10/13/2009




Administration