Cake php Datasource class MySQL could not be found

北城余情 提交于 2019-12-06 07:18:36

问题


I have ubuntu 10.04 on server. I am trying to set up the cake php project but it gives me following error

   Cake is NOT able to connect to the database.

   Datasource class MySQL could not be found.

I have searched lot on the web regarding it. my config file looks like this

  class DATABASE_CONFIG {

public $default = array(
    'datasource' => 'Database/MySQL',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'mypassword',
    'database' => 'dbname',
    'prefix' => '',
    //'encoding' => 'utf8',
);
 }

I checked that server has all the things set up to connect as PDO I have run following script and it works fine.

    $conn = new PDO('mysql:host=localhost;dbname=dbname', $username, $password);

Then further I have changed in Mysql.php file of cake php which is in the "lib\Cake\Model\Datasource\Database"

I tried to give static connection in Mysql.php but this also doesn't work. I did exit in the Mysql.php and seems like control of page is not getting here.

    $this->_connection = new PDO('mysql:host=localhost;dbname=dbname', $username, $password);
$this->connected = true;

Please do let me know if I am missing anything.

Thanks in Advance.


回答1:


Casing matters, it should be:

'datasource' => 'Database/Mysql'

And not:

'datasource' => 'Database/MySQL'



回答2:


Mysql is not a supported source try 'datasource' => 'Database/Sqlite',



来源:https://stackoverflow.com/questions/13208855/cake-php-datasource-class-mysql-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!