I created a console command and I need to trim the table.
Reading the class reference: http://www.yiiframework.com/doc-2.0/yii-db-command.html#truncateTable()-detail I canβt figure out which files I need to include to execute this command.
I'm turning on:
use yii\db\Command;
use yii\db\Connection;
but not sure which one is correct.
And I tried to execute:
$command = Yii::$app->db->truncateTable('user');
which gives me the following error:
Exception 'yii \ base \ UnknownMethodException' with the message 'Unknown method call: yii \ db \ Connection :: truncateTable ()'
and
Yii::$connection->createCommand()->truncateTable('user');
which gives me the following error:
PHP Fatal Error 'yii \ base \ ErrorException' with the message "Access to undeclared static property: Yii :: $ connection"
I really don't understand what I need to do.