Get database reflection from Connection instance

Eda
Member | 220
+
0
-

Hi.

In my application I want to work with database structure (foreign keys etc.). Is there any way, how can I get info about database structure from Nette\Connection instance which i have injected into my Presenter?

Is the right way creating of Nette\Database\DiscoveredReflection on my own? Or is there any way to inject IReflection into my Presenter?

Thanks.

enumag
Member | 2118
+
0
-

In Nette 2.0 there is Connection::getDatabaseReflection() method but it's missing in 2.1. The main reason is that Connection never used reflection directly so it doesn't need reflection.

In my opinion creating your own IReflection service is correct. Keep in mind though that you probably should not use database reflection in presenter directly.

EDIT: @Majkl578: That's 2.0 only and also it's getDatabaseReflection not just getReflection.

Last edited by enumag (4. 4. 2013 14:37)

hrach
Member | 1844
+
0
-

Solution is to rewirte it to use DI(C).
Until that you can use hack like

$connection->table('')->getDatabaseReflection();

See https://api.nette.org/…lection.html#…

Last edited by hrach (4. 4. 2013 17:16)

hrach
Member | 1844
+
0
-

I edited my ealier issue and reopened it :) https://github.com/…e/issues/931

Eda
Member | 220
+
0
-

I am using just Nette 2.1.

Hrach: thx for hack and reopening issue. I am looking forward to real fix :-)

RSS feed Topic closed