Example #1
4
 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;
 }
Example #2
0
 function write($data)
 {
     if (!($e = $this->_firstUse())) {
         return $e;
     }
     $ok = ibase_blob_add($this->blob, $data);
     if ($ok === false) {
         return $this->_setDbError('add data to');
     }
     return true;
 }
Example #3
0
 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;
 }
Example #4
0
 /**
  * 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 _quoteLOB($lob)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if (MDB2::isError($connect = $db->connect())) {
         return $connect;
     }
     $prepared_query = $GLOBALS['_MDB2_LOBs'][$lob]->prepared_query;
     $parameter = $GLOBALS['_MDB2_LOBs'][$lob]->parameter;
     $value = '';
     // DEAL WITH ME
     if (!($db->transaction_id = @ibase_trans(IBASE_COMMITTED, $db->connection))) {
         return $db->raiseError(MDB2_ERROR, null, null, 'Could not start a new transaction: ' . ibase_errmsg());
     }
     if ($lo = @ibase_blob_create($db->auto_commit ? $db->connection : $db->transaction_id)) {
         while (!$this->endOfLOB($lob)) {
             $result = $this->readLOB($lob, $data, $db->options['lob_buffer_length']);
             if (MDB2::isError($result)) {
                 break;
             }
             if (@ibase_blob_add($lo, $data) === false) {
                 $result = $db->raiseError(MDB2_ERROR, null, null, 'Could not add data to a large object: ' . ibase_errmsg());
                 break;
             }
         }
         if (MDB2::isError($result)) {
             @ibase_blob_cancel($lo);
         } else {
             $value = @ibase_blob_close($lo);
         }
     } else {
         $result = $db->raiseError();
     }
     if (!isset($db->query_parameters[$prepared_query])) {
         $db->query_parameters[$prepared_query] = array(0, '');
         $db->query_parameter_values[$prepared_query] = array();
     }
     $query_parameter = count($db->query_parameters[$prepared_query]);
     $db->query_parameters[$prepared_query][$query_parameter] = $value;
     $db->query_parameter_values[$prepared_query][$parameter] = $query_parameter;
     $value = '?';
     if (!$db->auto_commit) {
         $db->commit();
     }
     return $value;
 }
 /**
  * @brief updateAct 처리
  **/
 function _executeUpdateAct($output)
 {
     // 테이블 정리
     foreach ($output->tables as $key => $val) {
         $table_list[] = '"' . $this->prefix . $val . '"';
     }
     // 컬럼 정리
     foreach ($output->columns as $key => $val) {
         if (!isset($val['value'])) {
             continue;
         }
         $name = $val['name'];
         $value = $val['value'];
         $value = str_replace("'", "`", $value);
         if (strpos($name, '.') !== false && strpos($value, '.') !== false) {
             $column_list[] = $name . ' = ' . $value;
         } else {
             if ($output->column_type[$name] == "text" || $output->column_type[$name] == "bigtext") {
                 $blh = ibase_blob_create($this->fd);
                 ibase_blob_add($blh, $value);
                 $value = ibase_blob_close($blh);
             } else {
                 if ($output->column_type[$name] == 'number') {
                     // 연산식이 들어갔을 경우 컬럼명이 있는 지 체크해 더블쿼터를 넣어줌
                     preg_match("/(?i)[a-z][a-z0-9_-]+/", $value, $matches);
                     foreach ($matches as $key => $val) {
                         $value = str_replace($val, "\"" . $val . "\"", $value);
                     }
                     if ($matches != null) {
                         $column_list[] = sprintf("\"%s\" = %s", $name, $value);
                         continue;
                     }
                 }
             }
             $values[] = $value;
             $column_list[] = sprintf('"%s" = ?', $name);
         }
     }
     // 조건절 정리
     $condition = $this->getCondition($output);
     $query = sprintf("update %s set %s %s;", implode(',', $table_list), implode(',', $column_list), $condition);
     $result = $this->_query($query, $values);
     if (!$this->transaction_started) {
         @ibase_commit($this->fd);
     }
     return $result;
 }
Example #6
0
 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');
             }
         }
     }
 }
Example #7
0
 public function getData()
 {
     $blobId = ibase_blob_create();
     ibase_blob_add($blobId, $this->binary);
     return ibase_blob_close($blobId);
 }
            }
            ibase_query($fbdb, $csql, $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']);
 /**
  * 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;
 }
Example #10
-3
 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
         			)
         		)*/
     }
 }