Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate (set|get|load|)_<entity>_Object() for PK #1

Open
awbush opened this issue Oct 13, 2011 · 0 comments
Open

Generate (set|get|load|)_<entity>_Object() for PK #1

awbush opened this issue Oct 13, 2011 · 0 comments

Comments

@awbush
Copy link
Owner

awbush commented Oct 13, 2011

If there's a schema that has extended data in a different table that varies by a type ID, as in this example:

generic
-------
generic_id PK AUTO_INCREMENT
generic_type_id  (indicates which extended table to join to, e.g. extension1, extension2, etc.)
[fields common amongst all extensions]

generic_extension1
------------------
generic_id PK, not AUTO_INCREMENT
[fields specific to the extension]

generic_extension2
------------------
generic_id PK, not AUTO_INCREMENT
[fields specific to the extension]

Then one might except there to be getGeneric_Object() method on the GenericExtension* classes. However, perhaps because this is the primary key, Cough does not look for these relationships.

Current workaround is to provide the methods manually on an as-needed basis:

public function loadGeneric_Object()
{
    $this->setGeneric_Object(Generic::constructByKey($this->getKeyId()));
}

public function getGeneric_Object()
{
    if (!isset($this->objects['Generic_Object']))
    {
        $this->loadGeneric_Object();
    }
    return $this->objects['Generic_Object'];
}

public function setGeneric_Object($generic)
{
    $this->objects['Generic_Object'] = $generic;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants