Nette\InvalidArgumentException Table xxx.y' does not exist

Notice: This thread is very old.
esorimer
Member | 114
+
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).

CZechBoY
Member | 3608
+
0
-

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

esorimer
Member | 114
+
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…

CZechBoY
Member | 3608
+
0
-

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

esorimer
Member | 114
+
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.

CZechBoY
Member | 3608
+
0
-

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

esorimer
Member | 114
+
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 …?

CZechBoY
Member | 3608
+
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)

esorimer
Member | 114
+
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