0

пробую

    public function actionSell($id, $hero)
    {
        $table = 't_hero_has_equip';
        $id = 'hero_id';
        $has_equip_id = 'equip_id';
        $connection->createCommand()->insert($table, [
            $id => $hero,
            $has_equip_id => $id,
        ])->execute();

        return $this->redirect(['index']);
    }

получаю

PHP Fatal Error 'yii\base\ErrorException' with message 'Call to a member function
 createCommand() on a non-object' 

in F:\OpenServer\domains\yii2basic\modules\shop\controllers\ShopController.php:107

Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}

какой то неймспейс нужно подключить?

2

1 ответ 1

1

забыл

$connection = \Yii::$app->db;

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.