File: fk_request.php

package info (click to toggle)
ibwebadmin 0.98-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,892 kB
  • ctags: 1,965
  • sloc: php: 12,454; makefile: 7
file content (58 lines) | stat: -rw-r--r-- 1,980 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
// File           jsrs/fk_request.php / ibWebAdmin
// Purpose        answer to the requests send by the foreign key links in a watchtable panel
// Author         Lutz Brueckner <irie@gmx.de>
// Copyright      (c) 2000, 2001, 2002, 2003, 2004 by Lutz Brueckner,
//                published under the terms of the GNU General Public Licence v.2,
//                see file LICENCE for details
// Created        <03/01/03 23:26:02 lb>
//
// $Id: fk_request.php,v 1.6 2004/03/28 11:28:59 lbrueckner Exp $

require('../inc/configuration.inc.php');
require('../inc/session.inc.php');

session_start();
localize_session_vars();

require('../lang/' . (isset($s_cust) ? $s_cust['language'] : LANGUAGE) . '.inc.php');
require('../inc/functions.inc.php');
require('jsrsServer.php.inc');

if (DEBUG === TRUE) {
    include('../inc/debug_funcs.inc.php');
}

// answer to the request with the result of get_fk_values()
jsrsDispatch('get_fk_values');


// build the answer for the jsrs request
function get_fk_values($table, $column, $value){

    $dbhandle = db_connect();
    $sql = sprintf("SELECT * FROM %s WHERE %s='%s'", $table, $column, $value);
    $res = ibase_query($dbhandle, $sql) 
        or ib_error(__FILE__, __LINE__, $sql);

    if ($row = ibase_fetch_object($res)) {
        $close = "<a href='javascript:closeFK()'>[C]</a>";
        $html = "<table>\n<tr align=\"left\">\n<th colspan=\"2\"><nobr>".$close.'&nbsp;&nbsp;'.$sql."</nobr></th></tr>\n";
        foreach ($GLOBALS['s_fields'] as $field) {
            if ($field['table'] != $table) {
                continue;
            }
            $value = ($field['type'] == 'BLOB') ? '<i>BLOB</i>' : trim($row->$field['name']);
            $html .= sprintf("<tr>\n<td class=\"wttr1\">%s:</td><td class=\"wttr2\"><nobr>%s</nobr></td>\n</tr>\n", $field['name'] ,$value);
        } 
        $html .= "</table>\n";
    }
    else {
            $html = "Error!\n";
    }
    ibase_free_result($res);

    return $html;
}

?>