2
Good afternoon, you guys! I would like some help from you to solve a problem that is happening to me. I have a hexadecimal string containing an images that should be added to the database, when I do the Insert with PDO without the bindValue, passing the variable value directly to the SQL string, works perfectly:
$sql = "INSERT INTO arquivos (arquivo) Value($this->Arquivo)";
try{
$stmt = $this->db->prepare( $sql );
//outros campos...
$stmt->execute();
}...
however, if I do via bindValue:
$sql = "INSERT INTO arquivos (arquivo) Value(:Arquivo)";
try{
$stmt = $this->db->prepare( $sql );
$stmt->bindValue( ':Arquivo', $this->Arquivo );
$stmt->execute();
}...
the value is cut, and the image gets corrupted.
How do I fix this? is it a setup? I’d like to use it all via bindValue.
Your field is a blob?
– rray
What type of field used to save the hexadecimal file?
– Allan Andrade
@Allanandrade is a Blob field
– Jean Carlo
See if it works:
$stmt->bindValue( ':Arquivo', $this->Arquivo, PDO::PARAM_LOB);
– rray