86 lines
1.6 KiB
PHP
86 lines
1.6 KiB
PHP
|
<?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();
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
/* TEST DU DISPATCHER DES MANAGERS
|
||
|
*
|
||
|
* @return nomRetour<typeRetour> Description du retour
|
||
|
|
||
|
*/
|
||
|
function testModuleDispatcher(){
|
||
|
|
||
|
$req1 = new manager\ModuleRequest('firstModule/a', array('id_user' => 10) );
|
||
|
$req2 = manager\ModuleRequest::fromString('{"path": "firstModule/a", "data": [{"id_user":10}]}');
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
$instance = new manager\ModuleDispatcher($req1);
|
||
|
var_dump( $instance );
|
||
|
|
||
|
return true;
|
||
|
|
||
|
}testModuleDispatcher();
|
||
|
|
||
|
|
||
|
?>
|