$useDbConfig is now in the model

Published on January 24, 2006 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 June 17, 2008 at 21:35

    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 June 18, 2008 at 17:42

    @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