Call to undefined method ConnectionManager::getInstance() cakephp ugrade 1.3 to 2.0

StackOverflow https://stackoverflow.com/questions/22097633

  •  18-10-2022
  •  | 
  •  

Domanda

I am getting the error:

Error: Call to undefined method ConnectionManager::getInstance() File: /app/Controller/UsersController.php Line: 11

below are the function:

function changeDbSource($database = 'default') {   

    $db = ConnectionManager::getInstance();

    $connected = $db->getDataSource($database);

    if ($connected->isConnected()) {

        return true;

    } else {

        return false;

    }
}

please help.

È stato utile?

Soluzione

Try changing it to

function changeDbSource($database = 'default') {
    $db = ConnectionManager::getDataSource($database);
    return $db->isConnected();
}

getDataSource is now a static method

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top