Reputation: 13
I tried yii2 and postgres database but when I try to query my table i got an error . How to fix this?
LINK for my database connection:
Upvotes: 1
Views: 1483
Reputation: 167
maybe you don't set defaultSchema on connection string
return [
'class' => 'yii\db\Connection',
'dsn' => 'pgsql:host=localhost;dbname=db_name',
'username' => 'db_username',
'password' => 'db_password',
'charset' => 'utf8',
'schemaMap' => [
'pgsql'=> [
'class'=>'yii\db\pgsql\Schema',
'defaultSchema' => 'public' //specify your schema here
]
], // PostgreSQL
];
OR
change your tableName()
function in model like this
/**
* @inheritdoc
*/
public static function tableName()
{
return 'schemaName.table_name';
}
Upvotes: 4