我似乎无法弄清楚这一点,我正在尝试在我的应用程序中全球化所有数据库凭据,因此我在全局常量文件中设置数据库表名。我有一个查询,无论我尝试用多少种方法在字符串中设置常量变量,它都失败了。有人有想法么?
这是常量变量更改之前的查询,该查询有效:
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM crmManager");
以下是一些都失败的不同尝试(常量变量是 TBL_NAVIGATION):
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM " . TBL_NAVIGATION . ");
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM".TBL_NAVIGATION.");
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM".TBL_NAVIGATION);
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM {TBL_NAVIGATION}");
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM".TBL_NAVIGATION");
我什至尝试将其最初设置为变量:
$table = TBL_NAVIGATION;
$stmt = $dbh->prepare("SELECT MAX(salesPosition) FROM {table}");
// I've tried every possible way to include the variable
我怎样才能解决这个问题?谢谢!