2016-09-06 80 views

回答

1

如果您wan't運行它作爲SQL你可以做到這一點

$connection->createCommand('SELECT total_units, nav, total_units * nav as total FROM user_nav_stats where total_units !=0')->queryAll(); 

但我會使用QueryBuilder的。這是這樣的。 More can be found here

$rows = (new \yii\db\Query()) 
    ->select(['total_units', 'nav', 'total_units * nav as total']) 
    ->from('user_nav_stats') 
    ->where(['!=','total_units',0]) 
    ->all();