コード例 #1
0
ファイル: deck_util.php プロジェクト: jjjj222/hsinfo
function insert_card_to_deck($table, $card)
{
    global $CARD_TABLE_NAME, $CARD_VALID_ID_CONSTRAINT;
    foreach ($card as $name => $num) {
        #$query = "SELECT id FROM $CARD_TABLE_NAME WHERE name = \"$name\" AND id RLIKE '[0-9_][0-9]$';";
        $query = "SELECT id FROM {$CARD_TABLE_NAME} WHERE name = \"{$name}\" AND {$CARD_VALID_ID_CONSTRAINT};";
        #echo $query;
        #echo "<br>";
        $result = mysql_query($query);
        $count = @mysql_numrows($result);
        check_single_tuple($count, $name);
        #if ($count != 1) {
        #    error_msg("multiple($count) \"$name\"");
        #    #echo "ERROR: multiple $name";
        #    #echo "<br>"
        #}
        $id = mysql_result($result, 0, "id");
        #echo "id: $id, num: $num";
        #echo "<br>";
        $tuple = array();
        $tuple["id"] = $id;
        $tuple["num"] = $num;
        $query = mysql_insert_str($table, $tuple);
        #echo $query;
        #echo "<br>";
        exec_mysql_query($query);
    }
}
コード例 #2
0
ファイル: mysql_query.php プロジェクト: jjjj222/hsinfo
function create_deck_table($table)
{
    $query = "CREATE TABLE {$table} (id CHAR(20) PRIMARY KEY, num INT);";
    exec_mysql_query($query);
}
コード例 #3
0
ファイル: parse_hs_json.php プロジェクト: jjjj222/hsinfo
function insert_card_data($table, $arr)
{
    foreach ($arr as $set_type => $card_obj) {
        $card_array = (array) $card_obj;
        foreach ($card_array as $set_seq => $card_info_obj) {
            $data = array();
            $data["setType"] = $set_type;
            $data["setSeq"] = $set_seq;
            $card_info_array = (array) $card_info_obj;
            foreach ($card_info_array as $key => $value) {
                $value_type = gettype($value);
                $value_all = "";
                if ($value_type == "array") {
                    $value_all = implode(', ', $value);
                } else {
                    if ($value_type == "object") {
                        $value_all = implode(', ', (array) $value);
                    } else {
                        if ($value === false) {
                            $value_all = 0;
                        } else {
                            $value_all = $value;
                        }
                    }
                }
                #echo "setType=$set_type, setSeq=$set_seq";
                #echo "<br>";
                $data[$key] = mysql_real_escape_string($value_all);
            }
            $query = mysql_insert_str($table, $data);
            #echo $query;
            #echo "<br>";
            exec_mysql_query($query);
            #if ($data["id"] == "EX1_066") {
            #    exec_mysql_query($query);
            #}
        }
    }
}
コード例 #4
0
ファイル: delete_deck.php プロジェクト: jjjj222/hsinfo
<?php

include_once "../db/login.php";
include_once "global.php";
include_once "mysql_query.php";
include_once "html.php";
include_once "deck_util.php";
?>

<?php 
$link = @mysql_connect("{$servername}", "{$username}", "{$password}");
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die("Unable to select database");
#print_add_form();
$id = get_current_get_value("id");
$ids = get_attribute_values($DECK_TABLE_NAME, "id");
if (in_array($id, $ids)) {
    $deck_table_name = get_deck_table_name($id);
    drop_table($deck_table_name);
    $query = "DELETE FROM {$DECK_TABLE_NAME} WHERE id=\"{$id}\";";
    exec_mysql_query($query);
}
# close
mysql_close($link);