コード例 #1
0
ファイル: upload.post.php プロジェクト: sauger/forbes
    $name = array();
    $value = array();
    $set = array();
    foreach ($_POST as $k => $v) {
        if ($v) {
            $val = addslashes($line[$v - 1]);
            array_push($value, "'{$val}'");
            array_push($name, $k);
            if ($fields[$k]->Key != 'UNI') {
                array_push($set, "{$k}='{$val}'");
            }
        }
    }
    if ($code != 'no') {
        array_push($name, 'stock_code');
        $stock_code = conver_place($line[$code]);
        array_push($value, "'{$stock_code}'");
    }
    $name = implode(",", $name);
    $value = implode(",", $value);
    $sql = "insert into {$table_name} ({$name}) values ({$value})";
    if (!empty($set)) {
        $set = implode(",", $set);
        $sql .= " ON DUPLICATE KEY update {$set}";
    }
    array_push($sql_array, $sql);
}
foreach ($sql_array as $sql) {
    if ($db->execute($sql)) {
        $success++;
    } else {
コード例 #2
0
ファイル: upload.post.php プロジェクト: sauger/forbes_old
            break;
        case '日本':
            return 'JP';
            break;
        default:
            return '';
    }
}
$success = 0;
$fail = 0;
for ($i = 2; $i <= $data->sheets[0]['numRows']; $i++) {
    $company = new table_class('fb_company');
    foreach ($_POST as $k => $v) {
        $company->{$k} = addslashes($data->sheets[0]['cells'][$i][$v]);
    }
    $company->stock_place_code = conver_place($company->stock_place_code);
    if ($company->save()) {
        $success++;
    } else {
        $fail++;
        $str = "";
        foreach ($company->fields as $key => $val) {
            $str .= $val->value . " ";
        }
        array_push($fail_info, $str);
    }
}
$count = $success + $fail;
echo "共处理XLS数据{$count}条<br/>";
echo "成功{$success}条<br/>";
echo "失败{$fail}条<br/>";