Re: Best place to SET FOREIGN_KEY_CHECKS = 0
I'm not sure what "best place" means in this case ;-) but IMHO proper place is connect() method of datasource, so I would:
1. create new datasource class
#app/Model/Datasource/Database/MysqlNoConstraints.php
App::uses('Mysql', 'Model/Datasource/Database');
class MysqlNoConstraints extends Mysql {
public function connect() {
if (parent::connect()) {
$this->_connection->exec('SET FOREIGN_KEY_CHECKS = 0;');
return true;
}
return false;
}
}
2. either
a) define usage of (property for) that datasource in app/Config/database.php or
b)
$config = ConnectionManager::$config->default;
$config['datasource'] = 'Database/MysqlNoConstraints';
ConnectionManager::create('something', $config);
3. call setDataSource() on affected model(s)
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home