Insert blob firebird php

1

I have a problem when trying to insert a blob field in firebird my code is 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 you do ibase_blob_echo ($ file); the result is the

but after inserting when I select and then ibase_blob_echo ($ row-> FILE); I get the error that the blob id is invalid ..

Someone knows what I might be doing wrong.

Thanks in advance

    
asked by anonymous 03.08.2015 / 12:39

0 answers