Ejemplo n.º 1
0
 function form($id = '')
 {
     if ($id) {
         $data['id'] = $id;
         $data['user_data'] = $this->data_model->get_data_by_id($id);
         if (isset($data['user_data']['DESKRIPSI'])) {
             $blob_data = ibase_blob_info($data['user_data']['DESKRIPSI']);
             $blob_hndl = ibase_blob_open($data['user_data']['DESKRIPSI']);
             $deskripsi = ibase_blob_get($blob_hndl, $blob_data[0]);
             $data['user_data']['DESKRIPSI'] = $deskripsi;
         }
     }
     $data['title'] = 'SIPTU - BERITA';
     $data['main_content'] = 'master/berita';
     $this->load->view('layout/template', $data);
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 function _BlobDecode($blob)
 {
     if (ADODB_PHPVER >= 0x5000) {
         $blob_data = ibase_blob_info($this->_connectionID, $blob);
         $blobid = ibase_blob_open($this->_connectionID, $blob);
     } else {
         $blob_data = ibase_blob_info($blob);
         $blobid = ibase_blob_open($blob);
     }
     if ($blob_data[0] > $this->maxblobsize) {
         $realblob = ibase_blob_get($blobid, $this->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;
 }
Ejemplo n.º 4
0
 function _firstUse()
 {
     // BLOB is opened - nothing to do.
     if (is_resource($this->blob)) {
         return true;
     }
     // Open or create blob.
     if ($this->id !== null) {
         $this->blob = @ibase_blob_open($this->id);
         if ($this->blob === false) {
             return $this->_setDbError('open');
         }
     } else {
         $this->blob = @ibase_blob_create($this->database->link);
         if ($this->blob === false) {
             return $this->_setDbError('create');
         }
     }
     return true;
 }
Ejemplo n.º 5
0
 /**
 +----------------------------------------------------------
 * 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;
 }
Ejemplo n.º 6
0
 /**
  * fetch a lob value from a result set
  *
  * @param int $lob handle to a lob created by the createLob() function
  * @return mixed MDB2_OK on success, a MDB error on failure
  * @access private
  */
 function _retrieveLOB($lob)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if (!isset($db->lobs[$lob])) {
         return $db->raiseError(MDB2_ERROR, NULL, NULL, 'Retrieve LOB: it was not specified a valid lob');
     }
     if (!isset($db->lobs[$lob]['handle'])) {
         $db->lobs[$lob]['handle'] = @ibase_blob_open($db->lobs[$lob]['value']);
         if (!$db->lobs[$lob]['handle']) {
             unset($db->lobs[$lob]['value']);
             return $db->raiseError(MDB2_ERROR, NULL, NULL, 'Retrieve LOB: Could not open fetched large object field' . @ibase_errmsg());
         }
     }
     return MDB2_OK;
 }
Ejemplo n.º 7
0
 /**
  * retrieve LOB from the database
  *
  * @param array $lob array
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access protected
  */
 function _retrieveLOB(&$lob)
 {
     if (empty($lob['handle'])) {
         $lob['handle'] = @ibase_blob_open($lob['resource']);
         if (!$lob['handle']) {
             $db =& $this->getDBInstance();
             if (PEAR::isError($db)) {
                 return $db;
             }
             return $db->raiseError(null, null, null, 'Could not open fetched large object field', __FUNCTION__);
         }
     }
     $lob['loaded'] = true;
     return MDB2_OK;
 }
Ejemplo n.º 8
0
 function daftar_data_spt()
 {
     if (!isset($_POST['oper'])) {
         $this->load->model('spt_model');
         $id = $this->uri->segment(3);
         $page = $_REQUEST['page'];
         // get the requested page
         $limit = $_REQUEST['rows'];
         // get how many rows we want to have into the grid
         $sidx = $_REQUEST['sidx'];
         // get index row - i.e. user click to sort
         $sord = $_REQUEST['sord'];
         // get the direction if(!$sidx) $sidx =1;
         $req_param = array("id" => $id, "sort_by" => $sidx, "sort_direction" => $sord, "limit" => null, "search" => $_REQUEST['_search'], "search_field" => isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : null, "search_operator" => isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : null, "search_str" => isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : null);
         $row = $this->spt_model->get_data($req_param)->result_array();
         $count = count($row);
         if ($count > 0) {
             $total_pages = ceil($count / $limit);
         } else {
             $total_pages = 0;
         }
         if ($page > $total_pages) {
             $page = $total_pages;
         }
         $start = $limit * $page - $limit;
         // do not put $limit*($page - 1)
         if ($start < 0) {
             $start = 0;
         }
         $req_param['limit'] = array('start' => $start, 'end' => $limit);
         $result = $this->spt_model->get_data($req_param)->result_array();
         // sekarang format data dari dB sehingga sesuai yang diinginkan oleh jqGrid dalam hal ini pakai JSON format
         $response->page = $page;
         $response->total = $total_pages;
         $response->records = $count;
         for ($i = 0; $i < count($result); $i++) {
             $blob_data = ibase_blob_info($result[$i]['MAKSUD']);
             $blob_hndl = ibase_blob_open($result[$i]['MAKSUD']);
             $maksud = ibase_blob_get($blob_hndl, $blob_data[0]);
             $response->rows[$i]['id'] = $result[$i]['ID_SPT'];
             // data berikut harus sesuai dengan kolom-kolom yang ingin ditampilkan di view (js)
             $response->rows[$i]['cell'] = array($result[$i]['ID_SPT'], $result[$i]['SPT_NO'], date('d/m/Y', strtotime($result[$i]['TANGGAL'])), $maksud, $result[$i]['DARI'] . ' - ' . $result[$i]['TUJUAN'], date('d/m/Y', strtotime($result[$i]['TANGGAL_BERANGKAT'])) . ' - ' . date('d/m/Y', strtotime($result[$i]['TANGGAL_PULANG'])), $result[$i]['KENDARAAN'], $result[$i]['NAMA_PEGAWAI_PEMBERI'], $result[$i]['ID_PEGAWAI_PEMBERI'], $result[$i]['NAMA_PEGAWAI_PENERIMA'], $result[$i]['ID_PEGAWAI_PENERIMA']);
         }
         echo json_encode($response);
     } else {
         $id = $this->input->post('id');
         if ($_POST['oper'] === 'add') {
             //$this->tambah_data_spt();
         } else {
             if ($_POST['oper'] === 'edit') {
                 //$this->edit_data_spt($id);
             } else {
                 if ($_POST['oper'] === 'del') {
                     $this->hapus_spt($id);
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
 public function getBlob($data)
 {
     if (isset($data)) {
         $blob_data = @ibase_blob_info($data);
         $blob_hndl = @ibase_blob_open($data);
         $content = @ibase_blob_get($blob_hndl, $blob_data[0]);
         return $content;
     } else {
         return '';
     }
 }
Ejemplo n.º 10
0
 /**
  * @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;
 }
Ejemplo n.º 11
0
 function blob_read($tablename, $fieldname, $where = "0=1")
 {
     if ($this->debug) {
         echo "<pre style=\"color : green\">Reading blob in {$tablename} ({$fieldname}) where {$where} on {$this->dbpath} <p style=\"color:purple;\">  {$sql}</p></pre>";
     }
     switch ($this->dbtype) {
         /* Firebird Functionality */
         case "firebird":
             $sql = "select first 1 {$fieldname} from {$tablename} where {$where}";
             $this->reset_query();
             $object = $this->first_row($sql);
             $fieldname = strtoupper($fieldname);
             $blobfield = $object->{$fieldname};
             $blob_data = ibase_blob_info($this->dbh, $blobfield);
             $blob_hndl = ibase_blob_open($this->dbh, $blobfield);
             $content = ibase_blob_get($blob_hndl, $blob_data[0]);
             break;
             /* SQLite Functionality */
         /* SQLite Functionality */
         case "sqlite":
             $sql = "select first 1 {$fieldname} from {$tablename} where {$where}";
             $this->reset_query();
             $object = $this->first_row($sql);
             $fieldname = strtoupper($fieldname);
             $content = $object->{$fieldname};
             break;
             /* MYSQL Functionality */
         /* MYSQL Functionality */
         case "mysql":
             $sql = "select first 1 {$fieldname} from {$tablename} where {$where}";
             $this->reset_query();
             $object = $this->first_row($sql);
             $fieldname = strtoupper($fieldname);
             $content = $object->{$fieldname};
             break;
             /* Oracle Functionality */
         /* Oracle Functionality */
         case "oracle":
             //implement
             break;
             /* PGSQL Functionality */
         /* PGSQL Functionality */
         case "pgsql":
             // testing required
             $sql = "select first 1 {$fieldname} from {$tablename} where {$where}";
             $this->reset_query();
             $object = $this->first_row($sql);
             $fieldname = strtoupper($fieldname);
             $content = $object->{$fieldname};
             break;
     }
     if ($this->debug) {
         echo "<pre style=\"color : blue\">Query Executed on {$this->dbpath} \n </pre>";
     }
     return $content;
 }
 /**
  * fetch a lob value from a result set
  *
  * @param int $lob handle to a lob created by the createLob() function
  * @return mixed MDB_OK on success, a MDB error on failure
  * @access private
  */
 function _retrieveLob($lob)
 {
     if (!isset($this->lobs[$lob])) {
         return $this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: it was not specified a valid lob');
     }
     if (!isset($this->lobs[$lob]['Value'])) {
         $this->lobs[$lob]['Value'] = $this->fetch($this->lobs[$lob]['Result'], $this->lobs[$lob]['Row'], $this->lobs[$lob]['Field']);
         if (!($this->lobs[$lob]['Handle'] = @ibase_blob_open($this->lobs[$lob]['Value']))) {
             unset($this->lobs[$lob]['Value']);
             return $this->raiseError(MDB_ERROR, NULL, NULL, 'Retrieve LOB: Could not open fetched large object field' . @ibase_errmsg());
         }
     }
     return MDB_OK;
 }
Ejemplo n.º 13
0
 function &BlobDecode($blob)
 {
     $blobid = ibase_blob_open($blob);
     $realblob = ibase_blob_get($blobid, 299999);
     // 2nd param is max size of blob -- Kevin Boillet <*****@*****.**>
     ibase_blob_close($blobid);
     return $realblob;
 }
Ejemplo n.º 14
0
 function RetrieveLOB($lob)
 {
     if (!isset($this->lobs[$lob])) {
         return $this->SetError("Retrieve LOB", "it was not specified a valid lob");
     }
     if (!isset($this->lobs[$lob]["Value"])) {
         $this->lobs[$lob]["Value"] = $this->FetchResult($this->lobs[$lob]["Result"], $this->lobs[$lob]["Row"], $this->lobs[$lob]["Field"]);
         if (!($this->lobs[$lob]["Handle"] = ibase_blob_open($this->lobs[$lob]["Value"]))) {
             unset($this->lobs[$lob]["Value"]);
             return $this->SetError("Retrieve LOB", "Could not open fetched large object field: " . ibase_errmsg());
         }
     }
     return 1;
 }
Ejemplo n.º 15
0
<?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];
}
Ejemplo n.º 16
0
 function _BlobDecode($blob)
 {
     $blobid = ibase_blob_open($blob);
     $realblob = ibase_blob_get($blobid, $this->maxblobsize);
     // 2nd param is max size of blob -- Kevin Boillet <*****@*****.**>
     while ($string = ibase_blob_get($blobid, 8192)) {
         $realblob .= $string;
     }
     ibase_blob_close($blobid);
     return $realblob;
 }
Ejemplo n.º 17
0
 /**
  * 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;
 }