Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Override Database Prefix in a Model

edited July 2010 in Vanilla 2.0 - 2.8
I have a model that needs a different database prefix than the rest of the vanilla install (for integration with other systems).

Is it possible to set the full table name or prefix on one specific model?

Comments

  • ToddTodd Chief Product Officer Vanilla Staff
    edited July 2010
    I think you need to do something like the following in the model:
    $this->Database = clone $this->Database;
    $this->Database->DatabasePrefix = "YourPrefix";
    $this->SQL = clone $this->SQL;
    $this->SQL->Database = $this->Database;
    You can override the Model's constructor, but call parent::__construct(); before this.

    Hope this helps. If not, post back.
  • Sweet, works like a charm. Too bad it's cloning objects though just for a prefix change.
  • ToddTodd Chief Product Officer Vanilla Staff
    Yeah, the database prefix doesn't change that much, but it is necessary to keep it on the Database object.
  • LincLinc Detroit Admin
    Nice!
Sign In or Register to comment.