ERREUR: SQLSTATE[HY000] [2002] No such file or directory
<?php
error_reporting(0);
echo
'
<style type="text/css">
table
{
border-collapse: collapse;
}
td, th
{
padding: 2px;
}
table, td, th
{
border: 1px solid #999;
}
</style>
';
try
{
$obj_connexion = new PDO('mysql:dbname=test;host=localhost', 'test', base64_decode('GT8dAg9/NEsCACMGAkUhMw==') ^ 'ntSRCJu8rWVkv6Bx');
$arr_str_sql = array();
$arr_str_sql[] = 'insert test(libelle) values ("toto")';
foreach(range(1, 10) as $ii)
{
$arr_str_sql[] = 'insert test(libelle) values ("libelle '.$ii.'")';
}
$arr_str_sql[] = 'select * from test';
$arr_str_sql[] = 'update test set libelle="TATA" where libelle="toto"';
$arr_str_sql[] = 'update test set libelle=concat("tutu-", libelle) where libelle like "%libelle%"';
$arr_str_sql[] = 'delete from test where libelle="TATA"';
$arr_str_sql[] = 'delete from test where libelle like "%1%" or libelle like "%2%"';
$arr_str_sql[] = 'select * from test';
$arr_str_sql[] = 'select * from test where libelle like "%4%" or libelle like "%5%"';
$arr_str_sql[] = 'truncate test';
$arr_str_sql[] = 'KIKOULOL';
echo '<table><tr><th>sql</th><th>retour</th><th>rowCount()</th><th>count(fetchAll())</th><th>lastInsertId()</th></tr>';
foreach($arr_str_sql as $str_sql)
{
echo '<tr>';
$obj_statement = $obj_connexion->prepare($str_sql);
$bool_retour = $obj_statement->execute();
echo "<td>$str_sql</td>";
echo "<td>".var_export($bool_retour, true)."</td>";
echo "<td>".$obj_statement->rowCount()."</td>";
echo "<td>".count($obj_statement->fetchAll())."</td>";
echo "<td>".$obj_connexion->lastInsertId()."</td>";
echo '</tr>';
$obj_statement->closeCursor();
}
echo '</table>';
}
catch (PDOException $e)
{
echo 'ERREUR: ' . $e->getMessage();
}
echo '<hr />';
echo '</pre>';
highlight_file(__FILE__);