更新
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* 测试处方表字段
|
||||
* 访问: http://你的域名/test_prescription.php
|
||||
*/
|
||||
|
||||
// 引入ThinkPHP
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// 启动应用
|
||||
$app = new think\App();
|
||||
$app->initialize();
|
||||
|
||||
// 测试查询
|
||||
try {
|
||||
$db = \think\facade\Db::connect();
|
||||
|
||||
// 查询表结构
|
||||
$columns = $db->query("SHOW COLUMNS FROM zyt_tcm_prescription WHERE Field IN ('usage_time', 'usage_way', 'dietary_taboo', 'usage_notes', 'is_shared', 'usage_days')");
|
||||
|
||||
echo "<h2>数据库字段检查</h2>";
|
||||
echo "<pre>";
|
||||
print_r($columns);
|
||||
echo "</pre>";
|
||||
|
||||
// 逐个测试字段
|
||||
$testFields = ['usage_days', 'usage_time', 'usage_way', 'dietary_taboo', 'usage_notes', 'is_shared'];
|
||||
|
||||
echo "<h2>逐个字段测试</h2>";
|
||||
foreach ($testFields as $field) {
|
||||
try {
|
||||
$result = $db->table('zyt_tcm_prescription')
|
||||
->field("id, $field")
|
||||
->limit(1)
|
||||
->select();
|
||||
echo "<p style='color: green;'>✓ $field - 成功</p>";
|
||||
} catch (\Exception $e) {
|
||||
echo "<p style='color: red;'>✗ $field - 失败: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
}
|
||||
|
||||
// 尝试查询所有字段
|
||||
try {
|
||||
$data = $db->table('zyt_tcm_prescription')
|
||||
->field('id, sn, prescription_name, usage_days, usage_time, usage_way, dietary_taboo, usage_notes, is_shared')
|
||||
->limit(1)
|
||||
->select();
|
||||
|
||||
echo "<h2>完整查询结果</h2>";
|
||||
echo "<pre>";
|
||||
print_r($data);
|
||||
echo "</pre>";
|
||||
|
||||
echo "<h3 style='color: green;'>✓ 测试成功!所有字段可以正常访问</h3>";
|
||||
} catch (\Exception $e) {
|
||||
echo "<h3 style='color: red;'>✗ 完整查询失败</h3>";
|
||||
echo "<p>" . $e->getMessage() . "</p>";
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
echo "<h3 style='color: red;'>✗ 测试失败</h3>";
|
||||
echo "<p>错误信息: " . $e->getMessage() . "</p>";
|
||||
echo "<pre>" . $e->getTraceAsString() . "</pre>";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user