Avec test a7e.bigmac

This commit is contained in:
Claire DELBOS 2017-03-01 17:22:03 +01:00
parent 25ea178b80
commit 57a15f7abe

View File

@ -11,7 +11,7 @@ class Credit extends Scores_Ws_Server
public function getCredit() public function getCredit()
{ {
$this->authenticate(); $this->authenticate();
//$this->permission('credit'); $this->permission('searchent');
$idUser = $this->User->id; $idUser = $this->User->id;
@ -42,19 +42,32 @@ class Credit extends Scores_Ws_Server
public function infoCredit() public function infoCredit()
{ {
$info=new infoCredit(); $info=new infoCredit();
$this->authenticate(); $this->authenticate();
//$this->permission('credit'); //$this->permission('credit');
$idUser = $this->User->id; $idUser = $this->User->id;
$sql = "SELECT * FROM sdv1.credit__balance c if(intval($idUser)==0){
throw new SoapFault('MSG', 'Authentification défectueuse');
}
$sql = "SELECT * FROM sdv1.credit__balance c
WHERE c.idUser=:idUser"; WHERE c.idUser=:idUser";
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);
$stmt->bindValue('idUser', $idUser); $stmt->bindValue('idUser', $idUser);
try {
$stmt->execute(); $stmt->execute();
$res=$stmt->fetch(\PDO::FETCH_ASSOC); } catch(\Doctrine\DBAL\DBALException $e) {
if ($this->logger !== null) {
$this->logger->error($e->getMessage());
}
throw(new SoapFault('MSG', 'Acces base impossible'));
}
$info->balance=$res; if ($stmt->rowCount() > 0) {
$res=$stmt->fetch(\PDO::FETCH_ASSOC);
$info->balance=$res;
}else{
$info->balance=null;
}
$sql = "SELECT * FROM sdv1.credit__paid c $sql = "SELECT * FROM sdv1.credit__paid c
WHERE c.idUser=:idUser limit 100"; WHERE c.idUser=:idUser limit 100";
$stmt = $this->conn->prepare($sql); $stmt = $this->conn->prepare($sql);