function get_procedure_source($name)
{
    global $dbhandle;
    $psource = '';
    $sql = 'SELECT P.RDB$PROCEDURE_SOURCE PSOURCE' . ' FROM RDB$PROCEDURES P' . " WHERE P.RDB\$PROCEDURE_NAME='" . $name . "'";
    $res = fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    $obj = fbird_fetch_object($res);
    if (is_object($obj)) {
        $bid = fbird_blob_open($obj->PSOURCE);
        $arr = fbird_blob_info($obj->PSOURCE);
        // $arr[2] holds the blob length
        $psource = trim(fbird_blob_get($bid, $arr[0]));
        fbird_blob_close($bid);
    }
    fbird_free_result($res);
    return $psource;
}
Пример #2
0
function get_trigger_source($name)
{
    global $dbhandle;
    $tsource = '';
    $lsql = 'SELECT RDB$TRIGGER_SOURCE AS TSOURCE' . ' FROM RDB$TRIGGERS' . " WHERE RDB\$TRIGGER_NAME='" . $name . "'";
    $res = fbird_query($dbhandle, $lsql) or ib_error(__FILE__, __LINE__, $lsql);
    $obj = fbird_fetch_object($res);
    if (is_object($obj)) {
        $bid = fbird_blob_open($obj->TSOURCE);
        $arr = fbird_blob_info($obj->TSOURCE);
        // $arr[0] holds the blob length
        $tsource = trim(fbird_blob_get($bid, $arr[0]));
        fbird_blob_close($bid);
        // discard the 'AS ' from the source-string
        $tsource = substr($tsource, 3);
    }
    fbird_free_result($res);
    return $tsource;
}
Пример #3
0
 function OldUpdateBlob($table, $column, $val, $where, $blobtype = 'BLOB')
 {
     $blob_id = fbird_blob_create($this->_connectionID);
     fbird_blob_add($blob_id, $val);
     $blob_id_str = fbird_blob_close($blob_id);
     return $this->Execute("UPDATE {$table} SET {$column}=(?) WHERE {$where}", array($blob_id_str)) != false;
 }
Пример #4
0
     if (!empty($null_fields)) {
         foreach ($null_fields as $idx) {
             if ($data[$idx] == '') {
                 $data[$idx] = NULL;
             }
         }
     }
     // handle blobs
     if (!empty($blob_fields)) {
         foreach ($blob_fields as $idx) {
             if (empty($data[$idx])) {
                 $data[$idx] = NULL;
             } else {
                 $blob_handle = fbird_blob_create($dbhandle) or ib_error(__FILE__, __LINE__);
                 fbird_blob_add($blob_handle, $data[$idx]);
                 $data[$idx] = fbird_blob_close($blob_handle) or ib_error(__FILE__, __LINE__);
             }
         }
     }
     call_user_func_array('fbird_execute', array_merge(array($query), $data)) or $ib_error = ib_error(__FILE__, __LINE__, $query);
     // an error occurs during the import
     if (!empty($ib_error)) {
         break;
     }
     $csv_cnt++;
 }
 fclose($ihandle);
 $sql = '';
 // cleanup the watchtable output buffer
 $s_watch_buffer = '';
 $message .= sprintf($MESSAGES['CSV_IMPORT_COUNT'], $csv_cnt, $itable);
function get_blob_content($sql)
{
    global $dbhandle;
    $res = fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    $row = fbird_fetch_row($res);
    if ($blob_handle = @fbird_blob_open($row[0])) {
        $blob_info = fbird_blob_info($row[0]);
        $blob_length = $blob_info[0];
        $blob = fbird_blob_get($blob_handle, $blob_length);
        fbird_blob_close($blob_handle);
    } else {
        $blob = 'not a blob!';
    }
    return $blob;
}
function print_value($wt, $val, $type, $colname = NULL, $obj = NULL)
{
    if ($val === NULL) {
        $data = '<i>NULL</i>';
        $align = 'center';
    } elseif (strlen(trim($val)) == 0) {
        $data = '&nbsp;';
        $align = '';
    } elseif (in_array($type, array('CHARACTER', 'VARCHAR'))) {
        $data = htmlspecialchars(trim($val));
        $align = 'left';
    } elseif ($type != 'BLOB') {
        $data = trim($val);
        $align = 'right';
    } else {
        $inline_flag = FALSE;
        $data = '';
        if ($wt['tblob_inline'] == TRUE && $wt['blob_as'][$colname] == 'text') {
            $blob_handle = fbird_blob_open($val);
            $blob_info = fbird_blob_info($val);
            $blob_length = $blob_info[0];
            $data = htmlspecialchars(fbird_blob_get($blob_handle, $wt['tblob_chars']));
            fbird_blob_close($blob_handle);
            if ($blob_length > $wt['tblob_chars']) {
                $data .= ' ...&nbsp;';
            } else {
                $inline_flag = TRUE;
                $align = 'left';
            }
        }
        if (in_array($colname, $wt['blob_links']) && !$inline_flag) {
            $align = empty($data) ? 'center' : 'left';
            $url = url_session('showblob.php?where=' . get_where_str($obj) . '&table=' . $wt['table'] . '&col=' . $colname);
            $data .= '<i><a href="' . $url . '" target="_blank">BLOB</a></i>';
        }
        if ($data == '') {
            $align = 'center';
            $data = '<i>BLOB</i>';
        }
    }
    if (isset($wt['fks'][$colname])) {
        $link = sprintf("javascript:requestFKValues('%s', '%s', '%s')", $wt['fks'][$colname]['table'], $wt['fks'][$colname]['column'], $data);
        $data = '<a href="' . $link . '">' . $data . '</a>';
    }
    echo '<td' . (!empty($align) ? ' align="' . $align . '"' : '') . '>' . $data . '</td>';
}
Пример #7
0
function get_view_source($name)
{
    global $dbhandle;
    $vsource = '';
    $sql = 'SELECT R.RDB$VIEW_SOURCE VSOURCE' . ' FROM RDB$RELATIONS R' . " WHERE R.RDB\$RELATION_NAME='" . $name . "'";
    $res = fbird_query($dbhandle, $sql) or ib_error(__FILE__, __LINE__, $sql);
    $obj = fbird_fetch_object($res);
    if (is_object($obj)) {
        $bid = fbird_blob_open($obj->VSOURCE);
        $arr = fbird_blob_info($obj->VSOURCE);
        // $arr[0] holds the blob length
        $vsource = trim(fbird_blob_get($bid, $arr[0]));
        fbird_blob_close($bid);
    }
    fbird_free_result($res);
    return $vsource;
}
             $bindargs[] = empty($field['notnull']) && empty($value) ? NULL : $value;
             break;
         case 'BLOB':
             // blob from file-upload
             if (is_array($value) && strlen(trim($value['name'])) > 0) {
                 $bfname = $value['tmp_name'];
                 $bfhandle = fopen($bfname, 'r') or die('cannot open file ' . $bfname);
                 $bstr = fbird_blob_import($dbhandle, $bfhandle);
                 fclose($bfhandle);
                 $bindargs[] = $bstr;
             } elseif (isset($_POST['dt_edit_drop_blob_' . $instance . '_' . $k]) && empty($field['notnull'])) {
                 $bindargs[] = NULL;
             } elseif (!empty($value)) {
                 $bhandle = fbird_blob_create($dbhandle) or die('cannot create blob: ' . __FILE__ . ', ' . __LINE__);
                 fbird_blob_add($bhandle, $value);
                 $bstr = fbird_blob_close($bhandle);
                 $bindargs[] = $bstr;
             } else {
                 $bindargs[] = NULL;
             }
             break;
         default:
             if ($value == '') {
                 $value = NULL;
             }
             $bindargs[] = empty($field['notnull']) && strlen($value) == 0 ? NULL : $value;
     }
     $cols[] = $field['name'];
     $k++;
 }
 if (count($bindargs) > 0) {