我看过一个脚本,其中sql查询被写为:
$Query = "CREATE TABLE something (id INTEGER PRIMARY KEY AUTOINCREMENT, thing TEXT, ddno TEXT";
#Then normal statements here
#Then the script is closed here
$Query .= ")" ;
那么为什么不用右括号关闭上面的查询呢?是否有更多人可以通过这种方式实现这一目标?
答案 0 :(得分:2)
如果对查询有条件添加,可以做类似的事情:
$Query = "CREATE TABLE something (id INTEGER PRIMARY KEY AUTOINCREMENT, thing TEXT, ddno TEXT";
if ($add_column_x)
{
$Query .= ', column_x TEXT';
}
#Then the script is closed here
$Query .= ")" ;