新增批量

This commit is contained in:
杨志
2026-01-06 11:23:52 +08:00
parent e41dd33d23
commit cb7ad9a4b7
15 changed files with 1371 additions and 75 deletions

93
check_db_structure.php Normal file
View File

@@ -0,0 +1,93 @@
<?php
// 查看数据库表结构
require __DIR__ . '/vendor/autoload.php';
// 加载ThinkPHP框架
$app = new think\App();
$app->initialize();
use think\facade\Db;
try {
// 设置数据库配置(从.env读取或直接配置
$dbConfig = [
'default' => 'mysql',
'connections' => [
'mysql' => [
'type' => 'mysql',
'hostname' => '192.168.28.18',
'database' => 'dhd_official_test',
'username' => 'dhd_official_test',
'password' => '4zDsLWZaEzhPAGaf',
'hostport' => '3306',
'charset' => 'utf8',
]
]
];
// 设置配置
\think\facade\Config::set($dbConfig, 'database');
echo "========================================\n";
echo "查看数据库表结构\n";
echo "========================================\n\n";
// 查看职位表结构
echo "【职位表no_notice_position】\n";
echo "----------------------------------------\n";
$positionColumns = Db::query("DESC no_notice_position");
foreach ($positionColumns as $col) {
$field = $col['Field'] ?? $col['field'] ?? '';
$type = $col['Type'] ?? $col['type'] ?? '';
$null = ($col['Null'] ?? $col['null'] ?? '') === 'YES' ? 'NULL' : 'NOT NULL';
echo sprintf("%-30s %-20s %s\n", $field, $type, $null);
}
echo "\n【职位表示例数据前2条\n";
echo "----------------------------------------\n";
$positions = Db::name('no_notice_position')->limit(2)->select()->toArray();
foreach ($positions as $index => $pos) {
echo "记录 " . ($index + 1) . ":\n";
echo "ID: " . ($pos['id'] ?? '') . "\n";
echo "岗位名称: " . ($pos['positon_name'] ?? '') . "\n";
echo "学历要求: " . ($pos['education_require'] ?? '') . "\n";
echo "学位要求: " . ($pos['degree_require'] ?? '') . "\n";
echo "年龄要求: " . ($pos['age_require'] ?? '') . "\n";
echo "性别要求: " . ($pos['sex_require'] ?? '') . "\n";
echo "其他要求(JSON): " . ($pos['position_other_require'] ?? '') . "\n";
echo "\n";
}
echo "\n【用户表t_user】\n";
echo "----------------------------------------\n";
$userColumns = Db::query("DESC t_user");
foreach ($userColumns as $col) {
$field = $col['Field'] ?? $col['field'] ?? '';
$type = $col['Type'] ?? $col['type'] ?? '';
$null = ($col['Null'] ?? $col['null'] ?? '') === 'YES' ? 'NULL' : 'NOT NULL';
echo sprintf("%-30s %-20s %s\n", $field, $type, $null);
}
echo "\n【用户表示例数据前1条\n";
echo "----------------------------------------\n";
$users = Db::name('t_user')->limit(1)->select()->toArray();
if (!empty($users)) {
$user = $users[0];
echo "ID: " . ($user['id'] ?? '') . "\n";
echo "出生日期: " . ($user['birth_date'] ?? '') . "\n";
echo "性别: " . ($user['gender'] ?? '') . "\n";
// 只显示关键字段
$keyFields = ['id', 'birth_date', 'gender', 'education', 'majors_name'];
foreach ($keyFields as $field) {
if (isset($user[$field])) {
echo "$field: " . $user[$field] . "\n";
}
}
}
} catch (\Exception $e) {
echo "错误: " . $e->getMessage() . "\n";
echo "文件: " . $e->getFile() . ":" . $e->getLine() . "\n";
}