What does this mean exactly?
Array
(
[0] => Array
(
[MAX(nr_ficha)] => 13
)
)
I gave a print on the screen and saw that my foreign key (% with%) is getting value 13 (yes, that is the last value in the table), but I do not understand the rest of the code and nor why it does not work.
Notice: Array to string conversion in C: \ xampp \ htdocs \ TEST_BANCADA \ Models \ Teste.php on line 16
Fatal error: Uncaught PDOException: SQLSTATE [23000]: Integrity constraint violation: 1452 Can not add or update child row: a foreign key constraint fails (
nr_ficha
.teste__bancada
, CONSTRAINTteste
FOREIGN KEY (nr_ficha_teste
) REFERENCESnr_ficha
(cab_teste
)) in C: \ xampp \ htdocs \ TEST_CHANGE \ Models \ Test.php: 18 Stack trace: # 0 C: \ xampp \ htdocs \ TEST_CHANGE \ Models \ Test.php (18 ): PDO-> exec ('INSERT INTO tes ...') # 1 C: \ xampp \ htdocs \ TEST_CHANGE \ Controllers \ processa_testeq.php (30): Test-> register_test (Array, '4', ' 4 ',' 1 ') # 2 {main} thrown in C: \ xampp \ htdocs \ TESTE_BANCADA \ Models \ Teste.php on line 18
The function I used was this:
public function busca_ficha(){
$conexao = Database::getConnection();
$select="SELECT MAX(nr_ficha) FROM cab_teste";
$busca = $conexao->query($select);
$nr_ficha = $busca->fetchAll(PDO::FETCH_ASSOC);
return $nr_ficha;
}
And I called it that:
$ficha = new Cabecalho();
$nr_ficha = $ficha->busca_ficha();
Someone help me, please.