Connexion et requête sur oracle (en local)

master
Mehdi 5 years ago
parent 73f8522837
commit 09672c670d

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

@ -11,9 +11,10 @@ class SqliteDb extends SQLite3
function createTable(){ function createTable(){
$this->exec('DROP TABLE Correct'); $this->exec('DROP TABLE Correct');
$this->exec('CREATE TABLE Correct ( question STRING, reponse STRING)'); $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 ('Trouver le nombre de matchs joués par Kevin Durant', '68')");
$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 2 ', 'r2')"); //$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 2 ', 'r1')");
$this->exec("INSERT INTO Correct VALUES ('Ceci est la question 3 ', 'r3')"); $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'); require_once(__DIR__.'/config/Autoload.php');
Autoload::charger(); Autoload::charger();
$cont = new Controleur();?> $cont = new Controleur();
//phpinfo();
?>
</body> </body>
</html> </html>

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

Binary file not shown.

@ -22,7 +22,7 @@ and open the template in the editor.
?> ?>
<form action="Correcteur.php" method="post"> <form action="Correcteur.php" method="post">
<?php foreach ($dVueQuestions as $q) { ?> <?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> <p><input type="submit" value="Valider"></p>
</form> </form>
</body> </body>

Loading…
Cancel
Save