#6427: Specifying alternative datasource still loads 'default' datasource.
---------------------------+------------------------------------------------
Reporter: Sake | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Model
Version: 1.2 Final | Severity: Major
Keywords: | Php_version: PHP 5
Cake_version: 1.2.3.8166 |
---------------------------+------------------------------------------------
What I did is write a basic shell as follows:
{{{
// vendors/shells/gestionnaire.php
class GestionnaireShell extends Shell {
function initialize()
{
App::import('Model','BasicModel');
$gp = new BasicModel(array('ds'=>'other_datasource'));
parent::initialize();
}
function main()
{
}
}
}}}
What I expected is that the model would load fine and I could perform
functions on my model with all CRUD operations being applied on my
alternate datasource.
What happened is that the model instantiation failed because my var
$default = array( .. ) was pointing to a bad connection. Removing
'default' from my database config gave error "Fatal error:
ConnectionManager::getDataSource - Non-existent data source default in
/Users/edu/lib/cakephp/core/cake_1.2.3.8166/cake/libs/model/connection_manager.php
on line 109".
'''What is happening here?'''
After debugging, I realized that even though I instantiated my model using
:
{{{
$gp = new BasicModel(array('ds'=>'other_datasource'));
}}}
Somewhere in the call stack the model is being loaded with whatever is
specified in Model::useDbConfig (in my case, nothing so 'default' was
used). Behaviour after loading works fine, the model pulls data from the
alternate data source, but '''I can only get there if a $default
connection is defined and working'''.
This seems counter-intuitive. If I don't load any models with $default
datasource, it shouldn't fail. I'm explicitly using alternate datasources
because $default doesn't work in certain situations.
--
Ticket URL: <https://trac.cakephp.org/ticket/6427>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC.
Our primary goal is to provide a structured framework that enables PHP users at
all levels to rapidly develop robust web applications, without any loss to
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---