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

[1.3.4] inherited ChildModel::update() fails because it uses wrong schema (from parent) #3018

Closed
swen100 opened this issue Nov 11, 2014 · 0 comments

Comments

@swen100
Copy link

swen100 commented Nov 11, 2014

if a model (which inherits from parent one) changes the schema all find()-methods work fine, but update() fails. It uses the parent set schema, not its own.

my code example:

class parentModel extends \Phalcon\Mvc\Model {

    public static $database = 'blah';
    public static $source = '';

    public function initialize() {
        $this->setConnectionService('db');
        $this->setSchema(static::$database);
        $this->setSource(static::$source);
    }
}

class childModel extends parentModel {
    public static $database = 'rumble';
    public static $source = 'jungle';

    public function initialize() {
        parent::initialize();
        $this->useDynamicUpdate(true);
    }
}

// create a child, modify it and save the changes.
// simple, isn't it?
$object = childModel::findFirst("where ...");
$object->something = 'stupid';
$object->update();

result:
Error on save model Models\parentModel
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'blah.jungle' doesn't exist

So: the table was used correctly, the database (schema) not. It uses the parent model to save...

another interesting thing:

$object->getSchema()

gives: 'rumble' , which is correct.

maybe it is related to #2415

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@swen100 swen100 changed the title version 1.3.4: $inherited_model->update() fails because of (wrong) schema used from parent $inherited_model->update() fails because it uses wrong schema (from parent) Nov 13, 2014
@swen100 swen100 changed the title $inherited_model->update() fails because it uses wrong schema (from parent) Model::update() fails because it uses wrong schema (from parent) Nov 13, 2014
@swen100 swen100 changed the title Model::update() fails because it uses wrong schema (from parent) inherited Model::update() fails because it uses wrong schema (from parent) Nov 13, 2014
@swen100 swen100 changed the title inherited Model::update() fails because it uses wrong schema (from parent) [1.3.4] inherited Model::update() fails because it uses wrong schema (from parent) Nov 13, 2014
@swen100 swen100 changed the title [1.3.4] inherited Model::update() fails because it uses wrong schema (from parent) [1.3.4] inherited ChildModel::update() fails because it uses wrong schema (from parent) Nov 13, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants