Puoi controllare il valore di ritorno di ogni esecuzione di query e, se è false, mostrare un messaggio d'errore:
Codice PHP:
error_reporting(E_ALL);
// Connessione al database
$dbh = new \PDO('mysql:dbname=my_omgprova;host=localhost', 'omgprova', '');
if (!$dbh) {
die("Cannot connect to database");
}
// Esegue le query
$result = $dbh->query("UPDATE f_player SET playerValue='200000' WHERE playerOverall <='68' AND playerPosition='PT'");
if ($result === false) {
die($dbh->errorCode());
}
$result = $dbh->query("UPDATE f_player SET playerValue='300000' WHERE playerOverall = '69' AND playerPosition='PT'");
if ($result === false) {
die($dbh->errorCode());
}
$result = $dbh->query("UPDATE f_player SET playerValue='500000' WHERE playerOverall = '70' AND playerPosition='PT'");
if ($result === false) {
die($dbh->errorCode());
}
$result = $dbh->query("UPDATE f_player SET playerValue='600000' WHERE playerOverall = '71' AND playerPosition='PT'");
if ($result === false) {
die($dbh->errorCode());
}
// eccetera
Che puoi anche rendere in maniera più compatta usando die, se preferisci:
Codice PHP:
error_reporting(E_ALL);
// Connessione al database
$dbh = new \PDO('mysql:dbname=my_omgprova;host=localhost', 'omgprova', '');
if (!$dbh) {
die("Cannot connect to database");
}
// Esegue le query
$dbh->query("UPDATE f_player SET playerValue='200000' WHERE playerOverall <='68' AND playerPosition='PT'") or die($dbh->errorCode());
$dbh->query("UPDATE f_player SET playerValue='300000' WHERE playerOverall = '69' AND playerPosition='PT'") or die($dbh->errorCode());
$dbh->query("UPDATE f_player SET playerValue='500000' WHERE playerOverall = '70' AND playerPosition='PT'") or die($dbh->errorCode());
$dbh->query("UPDATE f_player SET playerValue='600000' WHERE playerOverall = '71' AND playerPosition='PT'") or die($dbh->errorCode());
// eccetera