function OldUpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB') { $blob_id = ibase_blob_create($this->_connectionID); ibase_blob_add($blob_id, $val); $blob_id_str = ibase_blob_close($blob_id); return $this->Execute("UPDATE {$table} SET {$column}=(?) WHERE {$where}", array($blob_id_str)) != false; }
function close() { if (!($e = $this->_firstUse())) { return $e; } if ($this->blob) { $id = ibase_blob_close($this->blob); if ($id === false) { return $this->_setDbError('close'); } $this->blob = null; } else { $id = null; } return $this->id ? $this->id : $id; }
function GetLOBFieldValue($prepared_query, $parameter, $lob, &$value) { if (!$this->Connect()) { return 0; } $success = 1; if ($blob = ibase_blob_create($this->auto_commit ? $this->connection : $this->transaction_id)) { while (!MetabaseEndOfLOB($lob)) { if (MetabaseReadLOB($lob, $data, $this->lob_buffer_length) < 0) { $this->SetError("Get LOB field value", MetabaseLOBError($lob)); $success = 0; break; } if (!ibase_blob_add($blob, $data)) { $this->SetError("Get LOB field value", "Could not add data to a large object: " . ibase_errmsg()); $success = 0; break; } } if ($success) { if (GetType($value = ibase_blob_close($blob))) { if (!isset($this->query_parameters[$prepared_query])) { $this->query_parameters[$prepared_query] = array(0, ""); $this->query_parameter_values[$prepared_query] = array(); } $query_parameter = count($this->query_parameters[$prepared_query]); $this->query_parameter_values[$prepared_query][$parameter] = $query_parameter; $this->query_parameters[$prepared_query][$query_parameter] = $value; $value = "?"; } else { $success = 0; } } if (!$success) { ibase_blob_cancel($blob); } } else { $this->SetError("Get LOB field value", "Could not create a large object: " . ibase_errmsg()); $success = 0; } return $success; }
/** * This function advances the reader to the next record. * * @access public * @override * @return boolean whether another record was fetched * * @see http://php.net/manual/en/function.ibase-blob-get.php */ public function read() { $this->record = @ibase_fetch_assoc($this->command); if ($this->record !== FALSE) { foreach ($this->blobs as $field) { $info = @ibase_blob_info($this->resource, $this->record[$field]); if (is_array($info) and !$info['isnull']) { $buffer = ''; $handle = @ibase_blob_open($this->resource, $this->record[$field]); if ($handle !== FALSE) { for ($i = 0; $i < $info[1]; $i++) { $size = $i == $info[1] - 1 ? $info[0] - $i * $info[2] : $info[2]; $value = @ibase_blob_get($handle, $size); if ($value !== FALSE) { $buffer .= $value; } } @ibase_blob_close($handle); } $this->record[$field] = $buffer; } else { $this->record[$field] = NULL; } } return TRUE; } return FALSE; }
/** +---------------------------------------------------------- * BLOB字段解密函数 Firebird特有 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @param $blob 待解密的BLOB +---------------------------------------------------------- * @return 二进制数据 +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ public function BlobDecode($blob) { $maxblobsize = 262144; $blob_data = ibase_blob_info($this->_linkID, $blob); $blobid = ibase_blob_open($this->_linkID, $blob); if ($blob_data[0] > $maxblobsize) { $realblob = ibase_blob_get($blobid, $maxblobsize); while ($string = ibase_blob_get($blobid, 8192)) { $realblob .= $string; } } else { $realblob = ibase_blob_get($blobid, $blob_data[0]); } ibase_blob_close($blobid); return $realblob; }
/** * Free any resources allocated during the lifetime of the large object * handler object. * * @param int $lob handle to a lob created by the createLob() function * @access private */ function _destroyResultLOB($lob) { $db =& $GLOBALS['_MDB2_databases'][$this->db_index]; if (isset($db->lobs[$lob])) { if (isset($db->lobs[$lob]['value'])) { @ibase_blob_close($db->lobs[$lob]['handle']); } $db->lobs[$lob] = ''; } }
<?php $results = ""; $head = "\\SetWatermarkText{" . $watermark . "}\n"; $head .= "\\normalsize Биоматериал: КРОВЬ ИЗ ВЕНЫ\n\n ~~~~~~~~~~~~~~~~СОСКОБ\n\n\\vspace{3px}"; $head .= "\\vspace{-10px} \\begin{center}\\large{\\textbf{Gine-Mix максима}}\n\\vspace{3px}\\rule{1\\linewidth}{0.1mm} \n \\normalsize{\\textbf{Маркеры опухолевого роста}} \\vspace{-5px} \n\n \\end{center}"; $apprdate = find_apprdate($ordersid, $dbh); $restm = "select o.comments_pic as com from orders ord inner join ordtask o on o.ordersid = ord.id where o.testcode =1912 and ord.id in(" . $ordersid . ")"; $row = ibase_query($restm); $data = ibase_fetch_object($row); $blob_data = ibase_blob_info($data->COM); $blob_hndl = ibase_blob_open($data->COM); $comments = ibase_blob_get($blob_hndl, $blob_data[0]); $comments = str_replace('%', '\\%', $comments); $comments = str_replace('_', '\\_', $comments); ibase_blob_close($blob_hndl); ibase_free_result($row); $results .= "\n\n" . $comments; $apprusergist = ""; $restm = "select u.fullname from ordtask o inner join users u on u.usernam = o.appruser inner join tests t on t.id = o.testcode where o.ordersid in(" . $ordersid . ") and t.dept =4"; $res = ibase_query($dbh, $restm); while ($row = ibase_fetch_row($res)) { $apprusergist .= $row[0]; } ibase_free_result($res); $apprpcr = ""; $restm = "select u.fullname from ordtask o inner join users u on u.usernam = o.appruser inner join tests t on t.id = o.testcode where o.ordersid in(" . $ordersid . ") and t.dept =3"; $res = ibase_query($dbh, $restm); while ($row = ibase_fetch_row($res)) { $apprpcr .= $row[0]; }
/** * Free any resources allocated during the lifetime of the large object * handler object. * * @param array $lob array * @access protected */ function _destroyLOB(&$lob) { if (isset($lob['handle'])) { @ibase_blob_close($lob['handle']); unset($lob['handle']); } }
/** * @brief query xml에 navigation 정보가 있을 경우 페이징 관련 작업을 처리한다 * * 그닥 좋지는 않은 구조이지만 편리하다.. -_-; **/ function _getNavigationData($table_list, $columns, $left_join, $condition, $output) { require_once _XE_PATH_ . 'classes/page/PageHandler.class.php'; $query_groupby = ''; if ($output->groups) { foreach ($output->groups as $key => $val) { $group_list[] = $this->autoQuotes($val); } if (count($group_list)) { $query_groupby = sprintf(" GROUP BY %s", implode(", ", $group_list)); } } /* // group by 절이 포함된 SELECT 쿼리의 전체 갯수를 구하기 위한 수정 // 정상적인 동작이 확인되면 주석으로 막아둔 부분으로 대체합니다. // $count_condition = strlen($query_groupby) ? sprintf('%s group by %s', $condition, $query_groupby) : $condition; $total_count = $this->getCountCache($output->tables, $count_condition); if($total_count === false) { $count_query = sprintf('select count(*) as "count" from %s %s %s', implode(', ', $table_list), implode(' ', $left_join), $count_condition); if (count($output->groups)) $count_query = sprintf('select count(*) as "count" from (%s) xet', $count_query); $result = $this->_query($count_query); $count_output = $this->_fetch($result); $total_count = (int)$count_output->count; $this->putCountCache($output->tables, $count_condition, $total_count); } */ // 전체 개수를 구함 $count_query = sprintf("select count(*) as \"count\" from %s %s %s", implode(',', $table_list), implode(' ', $left_join), $condition); $total_count = $this->getCountCache($output->tables, $condition); if ($total_count === false) { $result = $this->_query($count_query); $count_output = $this->_fetch($result); if (!$this->transaction_started) { @ibase_commit($this->fd); } $total_count = (int) $count_output->count; $this->putCountCache($output->tables, $condition, $total_count); } $list_count = $output->list_count['value']; if (!$list_count) { $list_count = 20; } $page_count = $output->page_count['value']; if (!$page_count) { $page_count = 10; } $page = $output->page['value']; if (!$page) { $page = 1; } // 전체 페이지를 구함 if ($total_count) { $total_page = (int) (($total_count - 1) / $list_count) + 1; } else { $total_page = 1; } // 페이지 변수를 체크 if ($page > $total_page) { $page = $total_page; } $start_count = ($page - 1) * $list_count; // list_order, update_order 로 정렬시에 인덱스 사용을 위해 condition에 쿼리 추가 if ($output->order) { $conditions = $this->getConditionList($output); if (!in_array('list_order', $conditions) && !in_array('update_order', $conditions)) { foreach ($output->order as $key => $val) { $col = $val[0]; if (!in_array($col, array('list_order', 'update_order'))) { continue; } if ($condition) { $condition .= sprintf(' and "%s" < 2100000000 ', $col); } else { $condition = sprintf(' where "%s" < 2100000000 ', $col); } } } } $limit = sprintf('FIRST %d SKIP %d ', $list_count, $start_count); $query = sprintf('SELECT %s %s FROM %s %s %s', $limit, $columns, implode(',', $table_list), implode(' ', $left_join), $condition); if (strlen($query_groupby)) { $query .= $query_groupby; } if ($output->order) { foreach ($output->order as $key => $val) { $index_list[] = sprintf("%s %s", $this->autoQuotes($val[0]), $val[1]); } if (count($index_list)) { $query .= sprintf(" ORDER BY %s", implode(",", $index_list)); } } $query .= ";"; $result = $this->_query($query); if ($this->isError()) { if (!$this->transaction_started) { @ibase_rollback($this->fd); } $buff = new Object(); $buff->total_count = 0; $buff->total_page = 0; $buff->page = 1; $buff->data = array(); $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); return $buff; } $virtual_no = $total_count - ($page - 1) * $list_count; while ($tmp = ibase_fetch_object($result)) { foreach ($tmp as $key => $val) { $type = $output->column_type[$key]; if ($type == null) { foreach ($output->columns as $cols) { if ($cols['alias'] == $key) { $type = $output->column_type[$cols['name']]; } } } if ($type == "text" || $type == "bigtext") { $blob_data = ibase_blob_info($tmp->{$key}); $blob_hndl = ibase_blob_open($tmp->{$key}); $tmp->{$key} = ibase_blob_get($blob_hndl, $blob_data[0]); ibase_blob_close($blob_hndl); } } $data[$virtual_no--] = $tmp; } if (!$this->transaction_started) { @ibase_commit($this->fd); } $buff = new Object(); $buff->total_count = $total_count; $buff->total_page = $total_page; $buff->page = $page; $buff->data = $data; $buff->page_navigation = new PageHandler($total_count, $total_page, $page, $page_count); return $buff; }
function save_image($id, $count) { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; //$config['max_size'] = '100'; //$config['max_width'] = '1024'; //$config['max_height'] = '768'; $this->load->library('upload', $config); foreach ($_FILES as $field => $value) { if (!$this->upload->do_upload($field)) { $error = array('error' => $this->upload->display_errors()); $this->firephp->log($error, 'upload gagal'); } else { $data = array('upload_data' => $this->upload->data()); $path_content = $data['upload_data']['full_path']; $path_content = str_replace('/', '\\', $path_content); $xx = $this->db->conn_id; if ($path_content != '') { $blh = ibase_blob_create($xx); ibase_blob_add($blh, file_get_contents($path_content)); $query = 'insert into foto(ASET_ID,DATAFOTO,THUMBFOTO,MEDIUMFOTO) values(' . $id . ',?,?,?)'; } $blobid = ibase_blob_close($blh); if (ibase_query($xx, $query, $blobid, $blobid, $blobid)) { $this->firephp->log('tersimpan'); } else { $this->firephp->log('tidak tersimpan'); } } } }
public function getData() { $blobId = ibase_blob_create(); ibase_blob_add($blobId, $this->binary); return ibase_blob_close($blobId); }
} else { $csql .= ',null,null)'; gcms_query($csql); } } else { $csql = 'update info_pemda set ' . 'kode_lokasi=' . quote_smart($_REQUEST['kodeLokasi']) . ',' . 'opt_kab=' . quote_smart($_REQUEST['kabKota']) . ',' . 'pejabat=' . quote_smart($_REQUEST['pejabat']) . ',' . 'pemda_alamat=' . quote_smart($_REQUEST['alamat']) . ',' . 'pemda_kabupaten=' . quote_smart($_REQUEST['namaKab']) . ',' . 'ibu_kota=' . quote_smart($_REQUEST['ibukotaKab']) . ',' . 'pemda_telp=' . quote_smart($_REQUEST['telp']) . ',' . 'pemda_fax=' . quote_smart($_REQUEST['fax']) . ',' . 'nama_bank=' . quote_smart($_REQUEST['namaBank']) . ',' . 'no_rekening=' . quote_smart($_REQUEST['noRek']); if (!empty($_FILES['logo']['tmp_name'])) { $tmpName = $_FILES['logo']['tmp_name']; //$fileSize = filesize($tmpName); $fileType = $_FILES['logo']['type']; global $fbdb; $blh = ibase_blob_create($fbdb); if ($_FILES['logo']['tmp_name'] != '') { ibase_blob_add($blh, file_get_contents($_FILES['logo']['tmp_name'])); } $blobid = ibase_blob_close($blh); $csql .= ",logo=?,tipe_gambar='" . $fileType . "'"; $target_file = './images/pemda/' . basename($_FILES['logo']['name']); if (!move_uploaded_file($_FILES['logo']['tmp_name'], $target_file)) { echo "File Gambar Gagal Di upload"; } ibase_query($fbdb, $csql, $blobid); } else { $csql .= ',logo=null,tipe_gambar=null'; gcms_query($sql); } } } unset($_FILES['logo']); $csql = "select * from info_pemda"; $nresult = gcms_query($csql);
/** * Convert a text value into a DBMS specific format that is suitable to * compose query statements. * * @param resource $prepared_query query handle from prepare() * @param $parameter * @param $lob * @return string text string that represents the given argument value in * a DBMS specific format. * @access private */ function _getLobValue($prepared_query, $parameter, $lob) { if (MDB::isError($connect = $this->connect())) { return $connect; } $value = ''; // DEAL WITH ME if (!($this->transaction_id = @ibase_trans(IBASE_COMMITTED, $this->connection))) { return $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: Could not start a new transaction: ' . @ibase_errmsg()); } if ($lo = @ibase_blob_create($this->auto_commit ? $this->connection : $this->transaction_id)) { while (!$this->endOfLob($lob)) { if (MDB::isError($result = $this->readLob($lob, $data, $this->options['lob_buffer_length']))) { break; } if (@ibase_blob_add($lo, $data) === false) { $result = $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue - Could not add data to a large object: ' . @ibase_errmsg()); break; } } if (MDB::isError($result)) { @ibase_blob_cancel($lo); } else { $value = @ibase_blob_close($lo); } } else { $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value' . @ibase_errmsg()); } if (!isset($this->query_parameters[$prepared_query])) { $this->query_parameters[$prepared_query] = array(0, ''); $this->query_parameter_values[$prepared_query] = array(); } $query_parameter = count($this->query_parameters[$prepared_query]); $this->query_parameter_values[$prepared_query][$parameter] = $query_parameter; $this->query_parameters[$prepared_query][$query_parameter] = $value; $value = '?'; if (!$this->auto_commit) { $this->commit(); } return $value; }
/** * Get the content of a blob field * * @access public * @param field * @return string */ function get_blob($field) { $s = ''; if (isset($field)) { $blob_data = ibase_blob_info($field); $blob_hndl = ibase_blob_open($field); $s = ibase_blob_get($blob_hndl, $blob_data[0]); ibase_blob_close($blob_hndl); } return $s; }
function go_upload($pid = '') { //$this->config_upload(); //$ext = $this->findexts($_FILES['Filedata']['name']); //$config['upload_path'] = base_url().'assets/data_upload/rapat/'.basename($_FILES['Filedata']['name']); //$config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'uploads/'.basename($_FILES['Filedata']['name']); //$config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'uploads/'.$new_name; $config['upload_path'] = './uploads/'; //$config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'uploads'; $config['allowed_types'] = 'gif|jpg|png|pdf'; //$config['max_size'] = '100'; //$config['max_width'] = '1024'; //$config['max_height'] = '768'; $this->load->library('upload', $config); $this->upload->initialize($config); $ext = $this->upload->get_extension($_FILES['Filedata']['name']); $new_name = date('d.m.Y.H.i.s') . $ext; $blh = ibase_blob_create($this->db->conn_id); ibase_blob_add($blh, file_get_contents($_FILES['Filedata']['tmp_name'])); $blobid = ibase_blob_close($blh); $is_upload = TRUE; if (!@copy($_FILES['Filedata']['tmp_name'], $this->upload->upload_path . $new_name)) { if (!@move_uploaded_file($_FILES['Filedata']['tmp_name'], $this->upload->upload_path . $new_name)) { $is_upload = FALSE; } } //if (!$this->upload->do_upload('Filedata')) //if(!move_uploaded_file($_FILES['Filedata']['tmp_name'], $_SERVER["DOCUMENT_ROOT"].'uploads/')) //if(!move_uploaded_file($_FILES['Filedata']['tmp_name'], $this->upload->upload_path)) if (!$is_upload) { $error = $this->upload->display_errors(); //$this->session->set_flashdata('error','<div class="error">'.$error.'</div>'); echo $error; } else { //$this->load->model('rapat_file_model','file_rapat'); $id_rapat = isset($pid) ? $pid : $this->uri->segment('3'); $data = array('id_rapat' => $id_rapat, 'nama_file' => $_FILES['Filedata']['name'], 'lokasi_file' => $this->upload->upload_path, 'nama_tmp' => $new_name, 'data_file' => $_FILES['Filedata']['tmp_name'], 'tipe_file' => $ext); $query = 'insert into rapat_file(id_rapat,nama_file,nama_tmp,data_file,lokasi_file,tipe_file) values(' . $this->db->escape($data['id_rapat']) . ',' . $this->db->escape($data['nama_file']) . ',' . $this->db->escape($data['nama_tmp']) . ',?,' . $this->db->escape($data['lokasi_file']) . ',' . $this->db->escape($data['tipe_file']) . ')'; $this->db->trans_start(); $insert = ibase_query($this->db->conn_id, $query, $blobid); $this->db->trans_complete(); //$this->file_rapat->insert_data($data); //$file = $this->upload->data(); //$file_list[] = array( //'name' => $CI->upload->file_name, //'file' => $CI->upload->upload_path.$CI->upload->file_name, //'size' => $CI->upload->file_size, //'type' => $CI->upload->file_type, //'ext' => $CI->upload->file_ext, /*Array ( [Filedata] => Array ( [name] => 2319233390_62fbfac7f5_b.jpg [type] => application/octet-stream [tmp_name] => C:\xampp\tmp\php2096.tmp [error] => 0 [size] => 143337 ) )*/ } }