Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Core;
- use Cake\Core\Configure;
- class CustomMysqlConnectionManager {
- public function __construct()
- {
- //Set credential properties
- $this->servername = Configure::read('myDataSource.host');
- $this->username = Configure::read('myDataSource.username');
- $this->password = Configure::read('myDataSource.password');
- $this->dbname = Configure::read('myDataSource.database');
- // Create connection
- $this->createConnction();
- }
- public function createConnction()
- {
- $this->conn = mysql_connect($this->servername, $this->username, $this->password);
- mysql_select_db($this->dbname, $this->conn);
- }
- public function execute($sql = '')
- {
- if(empty($sql)) {
- throw new Exception("Sql query not valid", 1);
- }
- $result = mysql_query($sql);
- return $result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement