2016-02-04 18:23:16 +00:00
|
|
|
<?php define('__ROOT__', dirname(__FILE__) );
|
|
|
|
require_once __ROOT__.'/manager/autoloader.php';
|
|
|
|
|
|
|
|
|
|
|
|
ini_set('display_errors',1);
|
|
|
|
ini_set('display_startup_errors',1);
|
|
|
|
error_reporting(-1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* NSERTION DES UTILISATEURS DANS LA BDD DEPUIS JSON
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function insertUsersFromJSON(){
|
|
|
|
$json = manager\ResourcesDispatcher::getRessource('/f/json/generated_users/conf');
|
|
|
|
$json = json_decode( $json, true );
|
|
|
|
|
|
|
|
// Pour chaque entree
|
|
|
|
foreach( $json as $user ){
|
|
|
|
|
|
|
|
$insertRequest = manager\Database::getPDO()->prepare("INSERT INTO user(id_user, code, username, firstname, lastname, mail, password, status)
|
|
|
|
VALUES(
|
|
|
|
DEFAULT,
|
|
|
|
:code,
|
|
|
|
:username,
|
|
|
|
:firstname,
|
|
|
|
:lastname,
|
|
|
|
:mail,
|
|
|
|
:password,
|
|
|
|
:status
|
|
|
|
)");
|
|
|
|
|
|
|
|
$status = $insertRequest->execute(array(
|
|
|
|
':code' => $user['code'],
|
|
|
|
':username' => $user['username'],
|
|
|
|
':firstname' => $user['firstname'],
|
|
|
|
':lastname' => $user['lastname'],
|
|
|
|
':mail' => $user['email'],
|
|
|
|
':password' => $user['password'],
|
|
|
|
':status' => $user['status']
|
|
|
|
));
|
|
|
|
|
|
|
|
var_dump( $status );
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}// insertUsersFromJSON();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* AFFICHAGE DES UTILISATEURS DE LA BDD
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @return status<Boolean> TRUE si aucune erreur, sinon FALSE
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
function selectUsers(){
|
|
|
|
|
|
|
|
// Creation de la requete
|
|
|
|
$requete = new manager\ModuleRequest('firstModule/getUsers');
|
|
|
|
|
|
|
|
var_dump( $requete->dispatch() );
|
|
|
|
|
|
|
|
|
|
|
|
var_dump( $users );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}//selectUsers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-04 18:23:16 +00:00
|
|
|
/* TEST DU DISPATCHER DES MANAGERS
|
|
|
|
*
|
|
|
|
* @return nomRetour<typeRetour> Description du retour
|
|
|
|
|
|
|
|
*/
|
|
|
|
function testModuleDispatcher(){
|
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
// Creation d'une requete en objet
|
|
|
|
$req1 = new manager\ModuleRequest('firstModule/printvar', array('id_user' => 10, 'code' => '11-22-33-44') );
|
|
|
|
// Creation d'une requete a partir d'un json en <String>
|
|
|
|
$req2 = manager\ModuleRequest::fromString('{"path": "firstModule/returnvar", "data": {"id_user":10, "code":"11-22-33-44"}}');
|
2016-02-04 18:23:16 +00:00
|
|
|
|
2016-02-04 19:21:01 +00:00
|
|
|
var_dump( $req2->dispatch() );
|
2016-02-04 18:23:16 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}testModuleDispatcher();
|
|
|
|
|
|
|
|
|
|
|
|
?>
|