Open shranet opened 5 years ago
I have two configurations for database connections! In all configurations host, dbname, username and password are same value!
//Yii::$app->db return [ 'class' => 'yii\db\Connection', 'dsn' => 'pgsql:host=***;dbname=***', 'username' => '***', 'password' => '***', 'charset' => 'utf8', 'schemaMap' => [ 'pgsql' => [ 'class' => 'yii\db\pgsql\Schema', 'defaultSchema' => 'public' //specify your schema here, public is the default schema ] ], // PostgreSQL ];
and
//Yii::$app->db2 return [ 'class' => 'yii\db\Connection', 'dsn' => 'pgsql:host=***;dbname=***', 'username' => '***', 'password' => '***', 'charset' => 'utf8', 'schemaMap' => [ 'pgsql' => [ 'class' => 'yii\db\pgsql\Schema', 'defaultSchema' => 'public', //specify your schema here, public is the default schema 'columnSchemaClass' => [ 'class' => yii\db\pgsql\ColumnSchema::class, 'disableJsonSupport' => true, 'disableArraySupport' => true, 'deserializeArrayColumnToArrayExpression' => false, ], ] ], // PostgreSQL ];
In second configuration I disable disableJsonSupport and disableArraySupport! And I used like this:
$result1 = CountriesModel::find()->where(["id" => 1])->one(); $result2 = CountriesModel::find()->where(["id" => 1])->one(Yii::$app->db2); print_variable($result1->attributes); print_variable($result2->attributes);
Lonely result:
Array ( [id] => 1 [name] => Array ( [en] => Aruba [ru] => Aruba [uz] => Aruba ) [long_name] => Array ( [en] => Aruba [ru] => Aruba [uz] => Aruba ) [slug] => Array ( [en] => aruba [ru] => aruba [uz] => ) [iso2] => AW [iso3] => ABW [status] => 1 [created_at] => 2018-11-07 10:47:00 [updated_at] => 2018-11-19 12:27:26 )
Sorry my english! I use Google uncle :)
@SilverFire looks like it's connected to the feature you've introduced. Mind taking a look?
I have two configurations for database connections! In all configurations host, dbname, username and password are same value!
and
In second configuration I disable disableJsonSupport and disableArraySupport! And I used like this:
Lonely result:
and
Sorry my english! I use Google uncle :)