Exemplo n.º 1
0
 function BeginTrans()
 {
     if ($this->transOff) {
         return true;
     }
     $this->transCnt += 1;
     $this->autoCommit = false;
     $this->_transactionID = fbird_trans($this->ibasetrans, $this->_connectionID);
     return $this->_transactionID;
 }
Exemplo n.º 2
0
function export_data($export)
{
    global $s_fields, $warning;
    ini_set('ibase.dateformat', $export['general']['date']);
    ini_set('ibase.timeformat', $export['general']['time']);
    ini_set('ibase.timestampformat', $export['general']['date'] . ' ' . $export['general']['time']);
    if ($export['format'] == 'sql' && $export['sql']['info']) {
        echo sql_export_info($export, replace_escape_sequences($export['sql']['lineend']));
    }
    foreach (export_queries($export) as $query) {
        if (DEBUG) {
            add_debug($query, __FILE__, __LINE__);
        }
        $trans = fbird_trans(TRANS_READ, $dbhandle);
        $res = @fbird_query($trans, $query);
        if ($res === FALSE) {
            $ib_error = fbird_errmsg();
            $warning = '';
            return FALSE;
        }
        $columns = $col_types = $num_fields = array();
        $num = fbird_num_fields($res);
        for ($idx = 0; $idx < $num; $idx++) {
            $info = fbird_field_info($res, $idx);
            $columns[] = $info['name'];
            $col_types[] = $info['type'];
            $num_fields[] = is_number_type(substr($info['type'], 0, strcspn($info['type'], '(')));
        }
        $tablename = $info['relation'];
        $export['query'] = array('source' => $query, 'columns' => $columns, 'col_types' => $col_types, 'num_fields' => $num_fields, 'result' => $res);
        switch ($export['format']) {
            case 'csv':
                export_csv_data($export);
                break;
            case 'sql':
                export_sql_data($export, $tablename);
                break;
            case 'ext':
                printf('Export data to %s is still not implemented!', $export['format']);
                break;
            default:
                echo 'Unsupported export format!';
        }
        fbird_free_result($res);
        fbird_commit($trans);
    }
}
Exemplo n.º 3
0
function get_indices($order, $dir)
{
    global $dbhandle;
    $order_field = $order == 'name' ? 'I.RDB$INDEX_NAME' : 'I.RDB$RELATION_NAME';
    $sql = 'SELECT I.RDB$INDEX_NAME AS INAME, ' . 'I.RDB$RELATION_NAME AS RNAME, ' . 'I.RDB$UNIQUE_FLAG AS UFLAG, ' . 'I.RDB$INDEX_INACTIVE AS IFLAG, ' . 'I.RDB$INDEX_TYPE AS ITYPE, ' . 'S.RDB$FIELD_NAME AS FNAME, ' . 'S.RDB$FIELD_POSITION AS POS ' . 'FROM RDB$INDICES I ' . 'JOIN RDB$INDEX_SEGMENTS S ' . 'ON S.RDB$INDEX_NAME=I.RDB$INDEX_NAME ' . 'WHERE (I.RDB$SYSTEM_FLAG IS NULL  OR  I.RDB$SYSTEM_FLAG=0)' . 'AND I.RDB$FOREIGN_KEY IS NULL ' . "AND I.RDB\$INDEX_NAME NOT STARTING WITH 'RDB\$' " . 'ORDER BY ' . $order_field . ' ' . $dir;
    $trans = fbird_trans(TRANS_READ, $dbhandle);
    $res = fbird_query($trans, $sql) or ib_error();
    $indices = array();
    while ($obj = fbird_fetch_object($res)) {
        if (!isset($indices[$obj->INAME])) {
            $iname = trim($obj->INAME);
            $indices[$iname]['table'] = trim($obj->RNAME);
            $indices[$iname]['dir'] = isset($obj->ITYPE) && $obj->ITYPE == 1 ? 'DESC' : 'ASC';
            $indices[$iname]['uniq'] = isset($obj->UFLAG) ? TRUE : FALSE;
            $indices[$iname]['active'] = isset($obj->IFLAG) && $obj->IFLAG == 1 ? FALSE : TRUE;
            $indices[$iname]['pos'] = $obj->POS;
        }
        $indices[$iname]['seg'][$obj->POS] = trim($obj->FNAME);
    }
    fbird_commit($trans);
    return $indices;
}
Exemplo n.º 4
0
 }
 // execute command/script by isql
 if (isset($isql_flag) && empty($error)) {
     list($binary_output, $binary_error) = isql_execute($sql_script);
     $s_sql['buffer'] = '';
     array_shift($binary_output);
     // discard the first line
     foreach ($binary_output as $line) {
         $s_sql['buffer'] .= nl2br(str_replace(' ', '&nbsp;', $line)) . "<br>\n";
     }
 } elseif ($s_connected == TRUE && empty($error)) {
     $s_sql['more'] = FALSE;
     $results = array();
     foreach ($lines as $lnr => $cmd) {
         $cnt = 0;
         $trans = fbird_trans(TRANS_WRITE, $dbhandle);
         $res = @fbird_query($trans, $cmd) or $ib_error = fbird_errmsg();
         // if sql_output-panel is open
         $idx = get_panel_index($s_sql_panels, 'sql_output');
         if ($s_sql_panels[$idx][2] == 'open') {
             // if the query have result rows
             if (is_resource($res) && @fbird_num_fields($res) > 0) {
                 $fieldinfo[$lnr] = get_field_info($res);
                 // save the rows for the output in the sql_output panel
                 while ($row = fbird_fetch_object($res)) {
                     $results[$lnr][] = get_object_vars($row);
                     $cnt++;
                     if ($cnt >= SHOW_OUTPUT_ROWS && !isset($_POST['sql_display_all'])) {
                         $s_sql['more'] = TRUE;
                         break;
                     }
Exemplo n.º 5
0
function get_column_fk_defs($cname, $iname)
{
    global $dbhandle;
    $defs = array('fk_name' => $cname);
    $trans = fbird_trans(TRANS_READ, $dbhandle);
    $sql = 'SELECT RDB$UPDATE_RULE,' . ' RDB$DELETE_RULE' . ' FROM RDB$REF_CONSTRAINTS' . " WHERE RDB\$CONSTRAINT_NAME='" . $cname . "'";
    $res = @fbird_query($trans, $sql) or ib_error(__FILE__, __LINE__, $sql);
    if ($res && ($row = fbird_fetch_row($res))) {
        fbird_free_result($res);
    }
    $defs['on_update'] = trim($row[0]);
    $defs['on_delete'] = trim($row[1]);
    $sql = 'SELECT I2.RDB$RELATION_NAME,' . ' SE.RDB$FIELD_NAME' . ' FROM RDB$INDICES I1' . ' INNER JOIN RDB$INDICES I2 ON I1.RDB$FOREIGN_KEY=I2.RDB$INDEX_NAME' . ' INNER JOIN RDB$INDEX_SEGMENTS SE ON I2.RDB$INDEX_NAME=SE.RDB$INDEX_NAME' . " WHERE I1.RDB\$INDEX_NAME='" . $iname . "'";
    $res = @fbird_query($trans, $sql) or ib_error(__FILE__, __LINE__, $sql);
    if ($res && ($row = fbird_fetch_row($res))) {
        fbird_free_result($res);
    }
    $defs['fk_table'] = trim($row[0]);
    $defs['fk_column'] = trim($row[1]);
    fbird_commit($trans);
    return $defs;
}