I'm trying to delete some rows of 'occupation_data' (table) but there are a foreign constraint, so I did a small php script to delete the data linked in the others tables and after delete it in occupation_data.
When I run the script I see a loading in browser but nothing appear, what tools should I use to debug this?
Thank you
Goldiman
Here my code:
<?php
error_reporting(E_ALL);
set_time_limit(60000); // There are more than 30 tables and 380 primary key to delete, may take time
ini_set("display_errors", 1);
$tupleasup = array(
'13-1199.05',
'13-1023.00',
'13-1022.00',
'53-6031.00'
); //Contain the primary key of the row
$table = array(
'abilities',
'education_training_experience',
'green_occupations',
'occupation_data'
);
try {
$VALEUR_hote = '**********';
$VALEUR_port = '******';
$VALEUR_nom_bd = '********';
$VALEUR_user = '*******';
$VALEUR_mot_de_passe = '*******'; //Working connection setting
$connexion = new PDO('mysql:host=' . $VALEUR_hote . ';port=' . $VALEUR_port . ';dbname=' . $VALEUR_nom_bd, $VALEUR_user, $VALEUR_mot_de_passe);
$connexion->exec("SET NAMES 'UTF8'");
$connexion->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "toto"; // This message is not displayed
foreach ($tupleasup as $codeOnet) {
foreach ($table as $nomTable) {
$query = "DELETE FROM " . $nomTable . " WHERE onetsoc_code =" . $codeOnet;
$resultats = $connexion->query($query);
}
echo "Supprimé" . $codeOnet; // This message is not displayed too.
}
}
catch (PDOException $e) {
echo 'Échec lors de la connexion : ' . $e->getMessage();
}
?>