Search tables in db for keyField; if found search key constraints
for the table to which it refers.
public findTableReferencedBy ( Cake\Database\Schema\Table $schema, string $keyField ) : string | null | ||
$schema | Cake\Database\Schema\Table | The table schema to find a constraint for. |
$keyField | string | The field to check for a constraint. |
리턴 | string | null | Either the referenced table or null if the field has no constraints. |
/** * test finding referenced tables using constraints. * * @return void */ public function testFindTableReferencedBy() { $invoices = TableRegistry::get('Invitations'); $schema = $invoices->schema(); $result = $this->Task->findTableReferencedBy($schema, 'not_there'); $this->assertNull($result); $result = $this->Task->findTableReferencedBy($schema, 'sender_id'); $this->assertEquals('users', $result); $result = $this->Task->findTableReferencedBy($schema, 'receiver_id'); $this->assertEquals('users', $result); }