Friday, September 21, 2012

Re: Database name with period/dot results in SQL error

Thanks for the tip. This I my first try at using CakePHP so I'm sorry to ask newbie questions - but I still don't get it to connect properly to the database. 

The problem is that the database itself has a period in in. As far as I can see this is set in a config variable: $config['database']. It is used several times in Model/Datasource/Database/Mysql.php.  But I can't find a good place to set it so that I don't have to make changes everywhere that the config['database'] value is used. 

I tried injecting the escaped database name in Model/Datasource/DataSource.php after line 284 like this: 

public function setConfig($config = array()) {
$this->config = array_merge($this->_baseConfig, $this->config, $config);
                $this->config['database'] = '`XXX.se`';
}

But this seems to mess up my connection and instead I get this error: 
Error: SQLSTATE[42000] [1044] Access denied for user 'XXX'@'YY.YY.YY.%' to database '`XXX.se`' requires a database connection 

Is there a better place to inject the escaped database name? 

/Johan

--
Like Us on FacekBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: