static function select($sql_or_array, $name, $request = null, $xtra = null, $blank_option = true) { $select = "<select name='{$name}' id='{$name}' {$xtra} >"; if ($blank_option) { $select .= "<option value=''>--Seleccionar--</option>"; } if (is_array($sql_or_array)) { if ($sql_or_array[0]) { foreach ($sql_or_array as $valor) { $select .= "<option value='{$valor}' " . ($request == $valor ? "selected" : "") . ">" . utf8_encode($valor) . "</option>"; } } else { foreach ($sql_or_array as $key => $valor) { $select .= "<option value='{$key}' " . ($request == $key ? "selected" : "") . ">" . utf8_encode($valor) . "</option>"; } } } else { $cnx = new db_mssql(); $cnx->set_type_result("num"); $arreglo = $cnx->get_registros($sql_or_array); if (!empty($arreglo)) { foreach ($arreglo as $registro) { $select .= "<option value='" . $registro[0] . "' " . ($request == $registro[0] ? "selected" : "") . ">" . utf8_encode($registro[1]) . "</option>"; } } } $select .= "</select>"; return $select; }
case 'import': $data = array(); @(include DT_ROOT . '/file/data/' . $name . '.php'); $data = dstripslashes($data); extract($data); if ($database == 'mysql') { if ($db_host && $db_user && $db_name) { $sc = new db_mysql(); $sc->connect($db_host, $db_user, $db_pass, $db_name, $CFG['db_expires'], $CFG['db_charset'], $CFG['pconnect']); } else { $sc =& $db; } } else { if ($database == 'mssql') { require DT_ROOT . '/include/db_mssql.class.php'; $sc = new db_mssql(); $sc->connect($db_host, $db_user, $db_pass, $db_name); } else { if ($database == 'access') { require DT_ROOT . '/include/db_access.class.php'; $sc = new db_access(); $sc->connect(DT_ROOT . '/' . $db_host, $db_user, $db_pass, $db_table); } else { msg('配置文件错误'); } } } $key = strpos($db_key, '.') !== false ? trim(substr(strrchr($db_key, '.'), 1)) : $db_key; if (!isset($fid)) { $r = $sc->get_one("SELECT min({$db_key}) AS fid FROM {$db_table} WHERE {$db_key}>{$lastid} {$db_condition}"); $fid = $r['fid'] ? $r['fid'] : 0;