mysqli bind_param nie ustawia $ stmt-> error lub $ stmt-> errno
Zgodnie z instrukcją php można pobierać błędy w dowolnej przygotowanej metodzie instrukcji, odpytując $ stmt-> error i $ stmt-> errno, jednak metoda bind_param nigdy nie wydaje się ustawiać na błąd, czy ktoś inny może to potwierdzić? lub powiedz mi, czego mi brakuje?
Na przykład:
echo "Start\n";
$db = new mysqli('localhost','test','xxxxxx','test');
$val = 1;
$st = $db->prepare('insert into tblTest set field1=?');
if($st == false)
{
printf("prepare: %s %d\n",$db->error,$st->errno);
}
$rs = $st->bind_param('is', $val);
if($rs == false)
{
printf("bind_param: %s %d\n",$st->error,$st->errno);
}
$rs = $st->execute();
if($rs == false)
{
printf("execute: %s %d\n",$st->error,$st->errno);
}
$rs = $st->close();
if($rs == false)
{
printf("close: %s %d\n",$st->error,$st->errno);
}
echo "Finish\n";
Uruchamianie powyższego z wiersza poleceń:
Start
PHP Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables in test.php on line 14
bind_param: 0
execute: No data supplied for parameters in prepared statement 2031
Finish
Tak więc php widzi to jako Ostrzeżenie, bind_param zwraca false, ale błąd i errno nie są ustawione. execute również zawodzi i poprawnie ustawił błąd i errno
Czy to błąd?