Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. $data = $this->request->data;
  2. $connection = ConnectionManager::get("default");
  3. $query = "SELECT * FROM clients WHERE client_id = ".$data['codigo'];
  4. $result = $connection->execute($query)->fetchAll('assoc');
  5.  
  6. ConnectionManager::drop('default');
  7.  
  8. $config = ConnectionManager::config('connection', [
  9. 'className' => 'CakeDatabaseConnection',
  10. 'driver' => 'CakeDatabaseDriverMysql',
  11. 'persistent' => false,
  12. 'host' => $result[0]['host'],
  13. 'username' => $result[0]['username'],
  14. 'password' => $result[0]['password'],
  15. 'database' => $result[0]['database'],
  16. 'encoding' => 'utf8',
  17. 'timezone' => 'UTC',
  18. 'flags' => [],
  19. 'cacheMetadata' => true,
  20. 'log' => false,
  21. 'quoteIdentifiers' => false,
  22. 'url' => env('DATABASE_URL', null),
  23. ]);
  24.  
  25. $connection = ConnectionManager::get('connection');
  26. ConnectionManager::alias('connection', 'default');
  27.  
  28. return $this->redirect(['controller' => 'Mains', 'action' => 'index']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement