$useDbConfig is now in the model

Published on and tagged with cakephp  tip

I just noticed that the variable $useDbConfig is no longer in the controller, the variable has been moved to the model. That makes sense.

For everyone who has never heard of this variable: $useDbConfig is used to specify which database configuration to use (you can define several database configurations in /app/config/database.php). In your model you simply say:

var $useDbConfig = 'myDBConfig';

2 comments baked

  • Tom

    Anyone stumbling upon this…it can now be $this->Model->setDataSource(‘configname’); in your controller. So you aren’t stuck with needing it in your model, though I personally would try to keep it set in the model if possible.

  • cakebaker

    @Tom: Thanks for the hint, and I agree with you that you should try to keep it set in the model.

Bake a comment

(for code please use <code>...</code> [no escaping necessary])

© daniel hofstetter. Licensed under a Creative Commons License