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?


  • Options
    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.
  • Options
    Sweet, works like a charm. Too bad it's cloning objects though just for a prefix change.
  • Options
    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.
  • Options
    LincLinc Detroit Admin
Sign In or Register to comment.