Skip to content

Instantly share code, notes, and snippets.

@ptheofan
Last active September 19, 2019 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptheofan/0a2444d8a88bea494120196d2377f71b to your computer and use it in GitHub Desktop.
Save ptheofan/0a2444d8a88bea494120196d2377f71b to your computer and use it in GitHub Desktop.
<?php
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
class Account extends ActiveRecord
{
public static function tableName()
{
return 'account';
}
public static function find()
{
return new ActiveQuery(self::class);
}
}
$a = Account::find()->andWhere(['id' => 1])->one();
$a->exp_lang = ['en', 'es'];
$a->save();
/*
This throws the following
PHP Notice 'yii\base\ErrorException' with message 'Array to string conversion'
in /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/ColumnSchema.php:157
Stack trace:
#0 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/QueryBuilder.php(647): yii\db\mysql\ColumnSchema->dbTypecast('???')
#1 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/QueryBuilder.php(625): yii\db\mysql\QueryBuilder->prepareUpdateSets('???', '???', '???')
#2 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/Command.php(580): yii\db\mysql\QueryBuilder->update('???', '???', '???', '???')
#3 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/ActiveRecord.php(330): yii\db\Command->update('???', '???', '???', '???')
#4 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/BaseActiveRecord.php(810): yii\db\ActiveRecord::updateAll('???', '???', '???')
#5 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/ActiveRecord.php(676): console\controllers\Account->updateInternal('???')
#6 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/db/BaseActiveRecord.php(681): console\controllers\Account->update('???', '???')
#7 /Users/ptheofan/Sites/radio/web/console/controllers/DummyController.php(49): console\controllers\Account->save('???', '???')
#8 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/InlineAction.php(57): console\controllers\DummyController->actionTest()
#9 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/InlineAction.php(57): ::call_user_func_array:{/Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/InlineAction.php:57}('???', '???')
#10 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams('???')
#11 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/console/Controller.php(148): console\controllers\DummyController->runAction('???', '???')
#12 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/Module.php(528): console\controllers\DummyController->runAction('???', '???')
#13 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/console/Application.php(180): yii\console\Application->runAction('???', '???')
#14 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('???', '???')
#15 /Users/ptheofan/Sites/radio/web/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest('???')
#16 /Users/ptheofan/Sites/radio/web/yii(27): yii\console\Application->run()
#17 {main}
*/
// Column was build with migrations using $this->json() and appears as
// `exp_lang` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL,
//
// DB is MariaDB (MySQL 5.5.5-10.2.14-MariaDB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment