forked from tom.biard/ScienceQuest
parent
3c94c2dde4
commit
1b1410fffd
@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/Neutral.iml" filepath="$PROJECT_DIR$/.idea/Neutral.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1 +1,34 @@
|
|||||||
|
<html>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
test
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
require_once("Connection.php");
|
||||||
|
|
||||||
|
//A CHANGER
|
||||||
|
$user= 'sasa';
|
||||||
|
$pass='sasa';
|
||||||
|
$dsn='mysql:host=localhost;dbname=siteperso';
|
||||||
|
try{
|
||||||
|
$con=new Connection($dsn,$user,$pass);
|
||||||
|
|
||||||
|
$query = "SELECT * FROM categorie WHERE id=:id";
|
||||||
|
|
||||||
|
|
||||||
|
echo $con->executeQuery($query, array(':id' => array(1, PDO::PARAM_INT) ) );
|
||||||
|
|
||||||
|
$results=$con->getResults();
|
||||||
|
Foreach ($results as $row)
|
||||||
|
print $row['titre'];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch( PDOException $Exception ) {
|
||||||
|
echo 'erreur';
|
||||||
|
echo $Exception->getMessage();}
|
||||||
|
?>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
class Connection extends PDO {
|
||||||
|
|
||||||
|
private $stmt;
|
||||||
|
|
||||||
|
public function __construct(string $dsn, string $username, string $password) {
|
||||||
|
|
||||||
|
parent::__construct($dsn,$username,$password);
|
||||||
|
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** * @param string $query
|
||||||
|
* @param array $parameters *
|
||||||
|
* @return bool Returns `true` on success, `false` otherwise
|
||||||
|
*/
|
||||||
|
|
||||||
|
public function executeQuery(string $query, array $parameters = []) : bool{
|
||||||
|
$this->stmt = parent::prepare($query);
|
||||||
|
foreach ($parameters as $name => $value) {
|
||||||
|
$this->stmt->bindValue($name, $value[0], $value[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->stmt->execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getResults() : array {
|
||||||
|
return $this->stmt->fetchall();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class ScientistGateway
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
enum Difficulty
|
||||||
|
{
|
||||||
|
case Easy;
|
||||||
|
case Medium;
|
||||||
|
case Hard;
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
class Scientist
|
||||||
|
{
|
||||||
|
private int $id;
|
||||||
|
private string $name;
|
||||||
|
private string $firstName;
|
||||||
|
private string $photo;
|
||||||
|
private string $description;
|
||||||
|
private Theme $theme;
|
||||||
|
private Difficulty $difficulty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $id
|
||||||
|
* @param string $name
|
||||||
|
* @param string $firstName
|
||||||
|
* @param string $photo
|
||||||
|
* @param string $description
|
||||||
|
* @param Theme $theme
|
||||||
|
* @param Difficulty $difficulty
|
||||||
|
*/
|
||||||
|
public function __construct(int $id, string $name, string $firstName, string $photo, string $description, Theme $theme, Difficulty $difficulty)
|
||||||
|
{
|
||||||
|
$this->id = $id;
|
||||||
|
$this->name = $name;
|
||||||
|
$this->firstName = $firstName;
|
||||||
|
$this->photo = $photo;
|
||||||
|
$this->description = $description;
|
||||||
|
$this->theme = $theme;
|
||||||
|
$this->difficulty = $difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getId(): int
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $name
|
||||||
|
*/
|
||||||
|
public function setName(string $name): void
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getFirstName(): string
|
||||||
|
{
|
||||||
|
return $this->firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $firstName
|
||||||
|
*/
|
||||||
|
public function setFirstName(string $firstName): void
|
||||||
|
{
|
||||||
|
$this->firstName = $firstName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPhoto(): string
|
||||||
|
{
|
||||||
|
return $this->photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $photo
|
||||||
|
*/
|
||||||
|
public function setPhoto(string $photo): void
|
||||||
|
{
|
||||||
|
$this->photo = $photo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return $this->description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $description
|
||||||
|
*/
|
||||||
|
public function setDescription(string $description): void
|
||||||
|
{
|
||||||
|
$this->description = $description;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Theme
|
||||||
|
*/
|
||||||
|
public function getTheme(): Theme
|
||||||
|
{
|
||||||
|
return $this->theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Theme $theme
|
||||||
|
*/
|
||||||
|
public function setTheme(Theme $theme): void
|
||||||
|
{
|
||||||
|
$this->theme = $theme;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Difficulty
|
||||||
|
*/
|
||||||
|
public function getDifficulty(): Difficulty
|
||||||
|
{
|
||||||
|
return $this->difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Difficulty $difficulty
|
||||||
|
*/
|
||||||
|
public function setDifficulty(Difficulty $difficulty): void
|
||||||
|
{
|
||||||
|
$this->difficulty = $difficulty;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace model;
|
||||||
|
|
||||||
|
enum Theme
|
||||||
|
{
|
||||||
|
case Maths;
|
||||||
|
case Physics;
|
||||||
|
case Chemistry;
|
||||||
|
}
|
Loading…
Reference in new issue