With reference to Doctrine DBAL 2.1.0 documentation, Sect. 9.5 
listTableForeignKeys(), I tried the given example as follows:

  private function getReferencesTo($tableName, $entityManager)
  {
    $conn = $entityManager->getConnection();
    $sm = $conn->getSchemaManager();
    $foreignKeys = $sm->listTableForeignKeys($tableName);
    foreach ($foreignKeys as $foreignKey)
      echo $foreignKey->getName() . ': ' . $foreignKey->getLocalTableName() 
."\n";
  }

This function is a member of my Controller. The result is:

Fatal error: Call to a member function getName() on a non-object in 
/home/gideon/devel/php/testapp/vendor/doctrine/dbal/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php
 
on line *108*

Sure enough, a var_dump($foreignKey) gives (note the second line 
'_localTable' => null):

*object*(*Doctrine\DBAL\Schema\ForeignKeyConstraint*)[*380*]
  *protected* '_localTable' => null
  *protected* '_localColumnNames' => 
    *array* *(size=1)*
      'priceGroup_id' => 
        *object*(*Doctrine\DBAL\Schema\Identifier*)[*374*]
          *protected* '_name' => string 'priceGroup_id' *(length=13)*
          *protected* '_namespace' => null
          *protected* '_quoted' => boolean false
  *protected* '_foreignTableName' => 
    *object*(*Doctrine\DBAL\Schema\Identifier*)[*369*]
      *protected* '_name' => string 'PriceGroups' *(length=11)*
      *protected* '_namespace' => null
      *protected* '_quoted' => boolean false
  *protected* '_foreignColumnNames' => 
    *array* *(size=1)*
      'id' => 
        *object*(*Doctrine\DBAL\Schema\Identifier*)[*370*]
          *protected* '_name' => string 'id' *(length=2)*
          *protected* '_namespace' => null
          *protected* '_quoted' => boolean false
  *protected* '_options' => 
    *array* *(size=2)*
      'onDelete' => null
      'onUpdate' => null
  *protected* '_name' => string 'FK_4ACC380C184C9230' *(length=19)*
  *protected* '_namespace' => null
  *protected* '_quoted' => boolean false


In class ForeignKeyConstraint, I found that _localTable must be set through 
foreignKeyConstraint->setLocalTable($table),
but from where is it supposed to be called, and how? (Note that $table is 
part of what I wanted listTableForeignKeys() to find for me in the first 
place...) 



-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to