0

I can get table columns with information about columns types by writting:

$table = new Zend_Db_Table('schema.table_name');
$info = $table->info();

There is information about Primary key, but nothing about Foreign keys.

Please help!

19th
  • 11
  • 2
  • (http://framework.zend.com/manual/1.12/en/zend.db.table.html#zend.db.table.info) descibes `referenceMap` gives foreign key info. – Deval Shah May 13 '13 at 10:10
  • (http://framework.zend.com/manual/1.12/en/zend.db.table.relationships.html#zend.db.table.relationships.defining) this is example of it – Deval Shah May 13 '13 at 10:11
  • This stuff works if you have defined this relations in your code. In my case relations not defined, so it would be nice if I could just get FK from DB. – 19th May 13 '13 at 10:17
  • then dude it not work anymore I think that – Deval Shah May 13 '13 at 10:21

2 Answers2

0

What your commentor is saying, is that Zend Framework 1x does not have the information about foreign keys or indexes available to the Zend_Db_Table_Abstract class.

You need to define a reference map so that information will become available. It would be nice if this information where available to the database adapter however I'm fairly sure that the availability of this information is uneven across the different databases and different database engines.

RockyFord
  • 8,529
  • 1
  • 15
  • 21
0

for table you can try using simple query like

use INFORMATION_SCHEMA;

select TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME,
REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME from KEY_COLUMN_USAGE where
REFERENCED_TABLE_NAME = '<table>';

for a table column, the same but add an and for the REFERENCED_COLUMN_NAME.

liyakat
  • 11,825
  • 2
  • 40
  • 46