#6124: Default datasource in Model when useTable is false
--------------------------+-------------------------------------------------
Reporter: mrjazz | Type: Bug
Status: new | Priority: Medium
Milestone: 1.2.x.x | Component: Model
Version: 1.2 Final | Severity: Normal
Keywords: | Php_version: n/a
Cake_version: |
--------------------------+-------------------------------------------------
Maybe it looks strange but sometimes I don't want to use default
connection (for example for starting tests on live system) but if Model
haven't table (useTable = false), setDataSource called with 'default'
datasource instead my 'test_suite'.
My soulution in constuctor of Model class:
{{{
if ($this->useTable !== false) {
$this->setDataSource($ds);
if ($this->useTable === null) {
$this->useTable =
Inflector::tableize($this->name);
} else {
$this->useTable =
Inflector::tableize($this->useTable);
}
if (method_exists($this, 'setTablePrefix')) {
$this->setTablePrefix();
}
$this->setSource($this->useTable);
$this->__createLinks();
if ($this->displayField == null) {
$this->displayField =
$this->hasField(array('title', 'name', $this->primaryKey));
}
} else if(isset($ds)) { // mrjazz patch begin
$this->setDataSource($ds);
} // mrjazz patch end
}}}
--
Ticket URL: <https://trac.cakephp.org/ticket/6124>
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
-~----------~----~----~----~------~----~------~--~---