我知道所有逻辑等都应该进入控制器,但我有一个 SQL 语句,其中的某些部分由另一个函数的返回值确定。
在我的模型中:
$cols = 'products.id, name, currencies.symbol, basePrice';
$m = new AuthController();
if($m->moduleExists('Sales'))
{
$cols .= 'lastSold';
}
或者在我的控制器中并将 SQL 作为参数传递给模型?
$cols = 'products.id, name, currencies.symbol, basePrice';
if($this->moduleExists('Sales'))
{
$cols .= 'lastSold';
}