1
i am having a problem when trying to insert a blob field in Firebird my code is the seguitne
$ficheiro = $this->blob_create(file_get_contents($_FILES['ficheiro']['tmp_name']));
$extensao = pathinfo($_FILES['ficheiro']['name'], PATHINFO_EXTENSION);
$nome = $_FILES['ficheiro']['name'];
$size = intval($_FILES['ficheiro']['size']);
$firebird->query("INSERT INTO DOCUMENTOS (ID_PAI, TIPO_PAI, FICHEIRO, DESCRICAO, TIPO_DOC, OBS, EXTENSAO, NOME_FICHEIRO, TAMANHO, DT_INSERCAO, DT_DOC) VALUES(".$this->db->escape($id).", ".$this->db->escape("MD_AGENDAMENTO").", ".$this->db->escape($ficheiro).", ".$this->db->escape($descricao).", ".$this->db->escape($tipo).", ".$this->db->escape($obs).", ".$this->db->escape(extensao).", ".$this->db->escape($nome).", ".$this->db->escape($size).", ".$this->db->escape(date("Y-m-d H:i:s")).", ".$this->db->escape($data).")");
public function blob_create($data) {
if(strlen($data) == 0)
return false;
$handle = ibase_blob_create();
$len = strlen($data);
for ($pos = 0; $pos < $len; $pos += 65535) {
$buflen = ($pos + 65535 > $len) ? ($len - $pos) : 65535;
$buf = substr($data,$pos,$buflen);
ibase_blob_add($handle,$buf);
}
return ibase_blob_close($handle);
}
before inserting if I do var_dump($file); die(); the result is 0x0000000100000000 if made ibase_blob_echo($file); the result is the file
but after inserting when I select and then ibase_blob_echo($line->FILE); I get the error that the blob id is invalid..
Does anyone know what I might be doing wrong.
Thanks in advance