Connexion et requête sur oracle (en local)

master
Mehdi 5 years ago
parent 73f8522837
commit 09672c670d

@ -7,23 +7,34 @@ require_once('SqliteDb.php');
header('Content-type: text/plain');
$db = new SqliteDb();
$conn = oci_connect('u_prems', '123456','localhost/orcl');
/*if(!$conn){
echo 'conn ERRROROR';
}
else {
echo 'conn SUCCCESSSS';
}*/
$cmpt = 0;
$i = 0;
foreach ($_POST['textbox'] as $textbox) {
$i++;
//$reponseUser = $_POST[''];
$query = $db->prepare('SELECT reponse FROM Correct WHERE rowid= ? ');
$query->bindParam(1, $i);
$result = $query->execute();
while($row = $result->fetchArray()){
if ($row['reponse'] == $textbox) {
echo "La réponse à la question n° ".$i." est JUSTE\n";
$cmpt++;
$i++;
$oracleQuery = oci_parse($conn, $textbox);
$reponseUser = oci_execute($oracleQuery);
$sqliteQuery = $db->prepare('SELECT reponse FROM Correct WHERE rowid= ? ');
$sqliteQuery->bindParam(1, $i);
$result = $sqliteQuery->execute();
while(($oracleRow = oci_fetch_array($oracleQuery, OCI_BOTH)) && ($sqliteRow = $result->fetchArray())){
echo 'oracle = ' . $oracleRow[0] . ' sqliet = ' . $sqliteRow[0] . '\n';
if ($sqliteRow['reponse'] == $oracleRow[0]) {
echo "La réponse à la question n° " . $i . " est JUSTE\n";
$cmpt++;
} else {
echo 'La réponse à la question n° ' . $i . " est FAUSSE\n\n";
}
else echo 'La réponse à la question n° '.$i." est FAUSSE\n\n";
}
}
echo 'Résultat ' . $cmpt . '/' . $i;

@ -11,9 +11,10 @@ class SqliteDb extends SQLite3
function createTable(){
$this->exec('DROP TABLE Correct');
$this->exec('CREATE TABLE Correct ( question STRING, reponse STRING)');
$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 1 ', 'r1')");
$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 2 ', 'r2')");
$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 3 ', 'r3')");
$this->exec("INSERT INTO Correct VALUES ('Trouver le nombre de matchs joués par Kevin Durant', '68')");
//$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 2 ', 'r1')");
$this->exec("INSERT INTO Correct VALUES ('Lister le(s) joueur(s) ayant joué le plus de match pendant la saison ', 'r2')");
}
}

@ -17,6 +17,9 @@ and open the template in the editor.
require_once(__DIR__.'/config/Autoload.php');
Autoload::charger();
$cont = new Controleur();?>
$cont = new Controleur();
//phpinfo();
?>
</body>
</html>

@ -3,11 +3,9 @@
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/C:/xampp/htdocs/BddCorrect/controleur/Controleur.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/modeles/Modele.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/index.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/vues/VuePrincipale.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/SqliteDb.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/DAL/QuestionsGateway.php</file>
<file>file:/C:/xampp/htdocs/BddCorrect/Correcteur.php</file>
</group>
</open-files>

Binary file not shown.

@ -22,7 +22,7 @@ and open the template in the editor.
?>
<form action="Correcteur.php" method="post">
<?php foreach ($dVueQuestions as $q) { ?>
<p><?php $i=0; $i++; echo $q->getQuestion(); ?> <br/> <input type="text" name="textbox[]" /></p><?php }?>
<p><?php $i=0; $i++; echo $q->getQuestion(); ?> <br/> <input type="text" name="textbox[]" size="100" /></p><?php }?>
<p><input type="submit" value="Valider"></p>
</form>
</body>

Loading…
Cancel
Save