我有一个问题,就是将数据插入到oracle数据库的表EMPLOYEES中。已经有一段时间了,我现在无法弄清楚我的代码出了什么问题。
这是我的html页面代码:employeeHire.php
<div class="container col-lg-6 col-md-10 mb-8 " >
<form action="employeHirePost.php" method="POST">
<p class="h4 text-center mb-4">Enregistrez un nouvel employé dans l'entreprise</p>
<label for="defaultFormLoginEmailEx" class="grey-text ">Entrez l'ID de L'employé</label>
<input type="text" id="defaultFormLoginEmailEx" name="id" class="form-control ">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Son Job ID</label>
<input type="text" id="defaultFormLoginPasswordEx" name="job"class="form-control">
<!--<select type="text" name="job" id="defaultFormLoginEmailEx" class="form-control ">
<option>Sélectionnez Job Id...</option>
<?php
$connection = new PDO("oci:dbname=localhost/XE", "hr", "123");
$reponse = $connection->query('SELECT job_id FROM jobs');
while ($donnees=$reponse->fetch()) {
echo "<option> $donnees[JOB_ID] </option>";
}
?>
</select>-->
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Son Nom</label>
<input type="text" id="defaultFormLoginPasswordEx" name="first_name" class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Son Prénom</label>
<input type="text" id="defaultFormLoginPasswordEx" name="last_name"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Son Email</label>
<input type="text" id="defaultFormLoginPasswordEx" name="email"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Son Numéro de Téléphone</label>
<input type="number" id="defaultFormLoginPasswordEx" name="phone"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Salaire</label>
<input type="number" id="defaultFormLoginPasswordEx" name="salaire"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Date D'embauche</label>
<input type="date" id="defaultFormLoginPasswordEx" name="hire_date"class="form-control">
<label for="defaultFormLoginPasswordEx" class="grey-text">Commission</label>
<input type="number" id="defaultFormLoginPasswordEx" name="com"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Manager id</label>
<input type="number" id="defaultFormLoginPasswordEx" name="man"class="form-control">
<br/>
<label for="defaultFormLoginPasswordEx" class="grey-text">Departement id</label>
<input type="number" id="defaultFormLoginPasswordEx" name="dep"class="form-control">
<br/>
<div class="text-center mt-4">
<button class="btn btn-indigo" class="waves-light" mdbTooltip="Cliquez pour enregistrer le nouvel employé" placement="top" mdbWavesEffect type="submit">Enregistrer Le Nouvel Employé</button>
</div>
</form>
</div>
这是ACTION页面,负责插入到DB :: employeeHirePost.php
<?php
include("connexion.php");
/*$date=date("d/m/y",strtotime($_POST['hire_date']));*/
if( isset($_POST['job']) ) {
$connection->beginTransaction();
$date = date('d/m/y', strtotime($_POST['hire_date']));
$request = $connection->prepare('INSERT INTO EMPLOYEES
(EMPLOYEE_ID,JOB_ID,FIRST_NAME,LAST_NAME,
EMAIL,PHONE_NUMBER,HIRE_DATE,SALARY,
COMMISSION_PCT,MANAGER_ID,DEPARTMENT_ID)
VALUES(?,?,?,?,?,?,?,?,?,?,?)');
$request->execute(array(intval($_POST['id']),$_POST['job'],
$_POST['first_name'],$_POST['last_name'],$_POST['email'],
$_POST['phone'],$date,intval($_POST['salaire']),
intval($_POST['com']),intval($_POST['man']),
intval($_POST['dep'])));
$connection->commit();
}
header('Location: employeHire.php');
?>
当我执行代码时就没有问题,就是它不会插入任何数据。拥有Oracle XE 11g的人可以尝试使用它。
答案 0 :(得分:-1)
Bonjour !!!!政法事务总书记处处长。政变甲骨文负责人甲骨文负责人与警察联系。