Nette\InvalidArgumentException Table xxx.y' does not exist

3 years ago

esorimer
Member | 106
+
0
-

I have updated nette 2.2 to 2.3.

Now, this code throws an exception:

return $this->database->table("xxx.yyyy");

I think it is similar problem to this issue: https://github.com/…base/pull/93

But this time its not problem of view, but of a table (yyyy) from a different database (xxx).

3 years ago

CZechBoY
Member | 3234
+
0
-

You should work with only one database. If you need another database then you have to inject other service. And disable autowire…

3 years ago

esorimer
Member | 106
+
0
-

Unfotunatelly, the databases are selected dynamically. It worked well with nette 2.2.

CZechBoY wrote:

You should work with only one database. If you need another database then you have to inject other service. And disable autowire…

3 years ago

CZechBoY
Member | 3234
+
0
-

Dynamically… and where do you store credentials and where do know which database you should use?

3 years ago

esorimer
Member | 106
+
0
-

CZechBoY wrote:

Dynamically… and where do you store credentials and where do know which database you should use?

I use only one connection to many databases. The name of the database is selected based on a few variables, most of them are in URL.

3 years ago

CZechBoY
Member | 3234
+
0
-

Try define own IStructure which prepends database name before table name.

3 years ago

esorimer
Member | 106
+
0
-

CZechBoY wrote:

Try define own IStructure which prepends database name before table name.

How can I use my own Structure? Is there any config option …?

3 years ago

CZechBoY
Member | 3234
+
0
-

In your config.local.neon

database:
    dsn: '...'
    user: '...'
    password: '...'
    structure: App\MySuperStructure

App\MySuperStructure.php

namespace App;

use Nette\Database\IStructure;

class MySuperStructure implements IStructure
{
    // implement interface
}

Last edited by CZechBoY (2016-05-23 15:22)

3 years ago

esorimer
Member | 106
+
0
-

Hi,
thanks. I had to change in DatabaseExtension class:

  1. change ->setClass(‘Nette\Database\Structure’) to ->setClass($config['structure'])
  2. add 'structure' => 'Nette\\Database\\Structure' to $databaseDefaults array.

Now it works