Hello,

I need to create an Install process for my application.

In some point during the intallation process I need to create the
database.php file and check if the cake is able to connect to the database.

The code to create the database.php file is:

$driver = $this->data['Database']['driver'];
$host = $this->data['Database']['host'];
$database = $this->data['Database'['database'];
$login = $this->data['Database']['login'];
$password = $this->data['Database']['password'];

$configFile = CONFIGS.'database.php';

$fp = fopen($configFilem, 'w');
fputs('$fp, "<?php\n");
fputs($fp, "class DATABASE_CONFIG {\n");
...
fputs($fp, "} ?>");

uses('model'.DS'.'connection_manager');
$ok = ConnectionManager::loadDataSource('default');
if ($ok === null) {
$this->Session->setFlash('Cannot los data source');
unlink($configFile);
return false;
}
$db = ConncetionManager::getInstance();
$dataSource = $db->getDataSource('default');
$canConnect = $dataSource->isConnected();
if (!$canConnect) {
$this->Session->setFlash('Cannot connect to Database');
unlink($configFile);
}
return $canConnect;

The problem is: I allways get the 'Cannot load data source message'. Is the
loadDataSource call ok, pleas help.

Thanks

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"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/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to