Beispiel #1
0
function do_meta_columns_named($reply, &$mdb2, $data, $table_name)
{
    $catalog = get_catalog($reply, &$mdb2);
    $res = $mdb2->reverse->tableInfo($table_name);
    if (PEAR::isError($res)) {
        return;
    }
    foreach ($res as $i => $value) {
        $xmlrow = $data->addChild("gda_array_row", null);
        add_value_child($xmlrow, $catalog);
        add_value_child($xmlrow, $catalog);
        add_value_child($xmlrow, $table_name);
        add_value_child($xmlrow, $value['name']);
        add_value_child($xmlrow, $i + 1);
        if ($value['default'] != "") {
            add_value_child($xmlrow, $value['default']);
        } else {
            add_value_child($xmlrow, null);
        }
        add_value_child($xmlrow, true, true);
        add_value_child($xmlrow, $value['nativetype']);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, mdb2_type_to_gtype($value['mdb2type']));
        add_value_child($xmlrow, $value['len']);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
        if ($value['autoincrement']) {
            add_value_child($xmlrow, "AUTO_INCREMENT");
        } else {
            add_value_child($xmlrow, null);
        }
        add_value_child($xmlrow, null);
        add_value_child($xmlrow, null);
    }
}
Beispiel #2
0
handle_pear_error($prep);
$res = $prep->execute(null);
handle_pear_error($res);
$reply = new SimpleXMLElement("<reply></reply>");
$node = $reply->addChild("gda_array", null);
$ncols = $res->numCols();
/* compute field type */
echo "M1\n";
$tableinfo = $mdb2->reverse->tableInfo($res, NULL);
echo "M2\n";
if (!PEAR::isError($tableinfo)) {
    //var_dump($tableinfo);
    $gtypes = array();
    $dbtypes = array();
    for ($i = 0; $i < $ncols; $i++) {
        $gtypes[$i] = mdb2_type_to_gtype($tableinfo[$i]['mdb2type']);
        $dbtypes[$i] = $tableinfo[$i]['type'];
    }
}
$colnames = $res->getColumnNames();
if (PEAR::isError($colnames)) {
    unset($colnames);
}
for ($i = 0; $i < $ncols; $i++) {
    $field = $node->addChild("gda_array_field", null);
    $field->addAttribute("id", "FI" . $i);
    if (isset($colnames)) {
        foreach ($colnames as $name => $pos) {
            if ($pos == $i) {
                $field->addAttribute("name", $name);
                break;
Beispiel #3
0
function do_exec($reply, &$mdb2, $pstmt_hash, $sql, $type_is_result, $argsnode)
{
    /* get prepared statement */
    global $prepared_statements;
    if (isset($pstmt_hash)) {
        $prep = $prepared_statements[(string) $pstmt_hash];
    }
    if (!isset($prep)) {
        $prep = do_prepare($reply, $mdb2, (string) $sql, $type_is_result, $argsnode);
    }
    /* handle arguments */
    if ($argsnode) {
        $args = array();
        foreach ($argsnode->children() as $node) {
            if ($node->getName() == "arg") {
                $args[] = $node[0];
            }
        }
    } else {
        $args = null;
    }
    /* actual execution */
    $res = $prep->execute($args);
    handle_pear_error($res, $reply);
    if ($type_is_result) {
        $node = $reply->addChild("gda_array", null);
        $ncols = $res->numCols();
        /* compute field type */
        $tableinfo = $mdb2->reverse->tableInfo($res, NULL);
        if (!PEAR::isError($tableinfo)) {
            //var_dump($tableinfo);
            $gtypes = array();
            $dbtypes = array();
            for ($i = 0; $i < $ncols; $i++) {
                $gtypes[$i] = mdb2_type_to_gtype($tableinfo[$i]['mdb2type']);
                $dbtypes[$i] = $tableinfo[$i]['type'];
            }
        }
        $colnames = $res->getColumnNames();
        if (PEAR::isError($colnames)) {
            unset($colnames);
        }
        for ($i = 0; $i < $ncols; $i++) {
            $field = $node->addChild("gda_array_field", null);
            $field->addAttribute("id", "FI" . $i);
            if (isset($colnames)) {
                foreach ($colnames as $name => $pos) {
                    if ($pos == $i) {
                        $field->addAttribute("name", $name);
                        break;
                    }
                }
            }
            if (isset($gtypes)) {
                $field->addAttribute("gdatype", $gtypes[$i]);
            } else {
                $field->addAttribute("gdatype", "string");
            }
            if (isset($dbtypes) && $dbtypes[$i]) {
                $field->addAttribute("dbtype", $dbtypes[$i]);
            }
            $field->addAttribute("nullok", "TRUE");
        }
        $data = $node->addChild("gda_array_data", null);
        while ($row = $res->fetchRow()) {
            // MDB2's default fetchmode is MDB2_FETCHMODE_ORDERED
            $xmlrow = $data->addChild("gda_array_row", null);
            for ($i = 0; $i < $ncols; $i++) {
                $val = $xmlrow->addChild("gda_value");
                $val[0] = str_replace("&", "&amp;", $row[$i]);
            }
        }
    } else {
        $reply->addChild("impacted_rows", (string) $res);
    }
}