4

I searched in every question an answer to this, but nothing found! This is the error when I enter in localhost/cakephp:

Notice (8): Undefined index: datasource [CORE\Cake\Model\ConnectionManager.php, line 258]

The other error:

Cake is NOT able to connect to the database.

Datasource class could not be found.

This is my config in database.php:

<?php
class DATABASE_CONFIG {
var $default = array('driver' => 'mysql',
                 'persistent'  => false,
                 'database' => '',
                     'host'        => 'localhost',
                     'login'       => 'lorizz',
                     'password'    => 'reyxD22!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');

var $test = array('driver' => 'mysql',
                 'persistent'  => false,
                  'database' => '',
                     'host'        => 'localhost',
                     'login'       => 'lorizz',
                     'password'    => 'reyxD22!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');

}
?>

Any answer?

7
  • What is the location of the file, and what is the location of APP? Commented Nov 11, 2012 at 18:14
  • Are you sure it is in the correct location (in the Config directory in you application folder)? It may be case sensitive. Commented Nov 11, 2012 at 18:15
  • Yes it's in cakephp -> APP -> Config Commented Nov 11, 2012 at 18:16
  • public $Mysql = array([...] ? It says it cant find connection "Mysql", so have you defined "Mysql" ? Commented Nov 11, 2012 at 18:16
  • ah it's public $default = array([...] Commented Nov 11, 2012 at 18:18

2 Answers 2

2

There you need to remove database used twice in your variables var $default and var $test

the config in database.php should be :

<?php
class DATABASE_CONFIG {
var $default = array('driver' => 'mysql',
                 'persistent'  => false,
                     'host'        => 'localhost',
                     'login'       => 'lorizz',
                     'password'    => 'reyxD22!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');

var $test = array('driver' => 'mysql',
                 'persistent'  => false,
                     'host'        => 'localhost',
                     'login'       => 'user',
                     'password'    => 'password!',
                     'database'    => 'test_database_name',
                     'prefix'      => '');

}
?>
Sign up to request clarification or add additional context in comments.

Comments

0

only change 'driver' => 'mysql', to 'datasource' => 'Database/Mysql',

<?php
class DATABASE_CONFIG {
public $default = array('datasource' => 'Database/Mysql',
                 'persistent'  => false,
                 'database' => '',
                     'host'        => 'localhost',
                     'login'       => 'lorizz',
                     'password'    => 'reyxD22!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');

public $test = array('datasource' => 'Database/Mysql',
                 'persistent'  => false,
                  'database' => '',
                     'host'        => 'localhost',
                     'login'       => 'lorizz',
                     'password'    => 'reyxD22!',
                     'database'    => 'my_cakephp_project',
                     'prefix'      => '');

}
?>

1 Comment

set database name and see the solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.