Advertisement
Guest User

Untitled

a guest
Jul 13th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Core;
  4.  
  5. use Cake\Core\Configure;
  6.  
  7. class CustomMysqlConnectionManager {
  8.  
  9. public function __construct()
  10. {
  11. //Set credential properties
  12. $this->servername = Configure::read('myDataSource.host');
  13. $this->username = Configure::read('myDataSource.username');
  14. $this->password = Configure::read('myDataSource.password');
  15. $this->dbname = Configure::read('myDataSource.database');
  16.  
  17. // Create connection
  18. $this->createConnction();
  19. }
  20.  
  21. public function createConnction()
  22. {
  23. $this->conn = mysql_connect($this->servername, $this->username, $this->password);
  24. mysql_select_db($this->dbname, $this->conn);
  25. }
  26.  
  27.  
  28. public function execute($sql = '')
  29. {
  30. if(empty($sql)) {
  31. throw new Exception("Sql query not valid", 1);
  32. }
  33.  
  34. $result = mysql_query($sql);
  35.  
  36. return $result;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement