Advertisement
xcoder_web

Classes

Jun 5th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. #CLASSE DE CONEXÃO
  2. <?php
  3.  
  4. <?php
  5.  
  6. include('../config/config.php');
  7. $op_cdb = new OP_Config();
  8.  
  9. class DB {
  10.     private $conn;
  11.  
  12.     public function getConnection($DATES_DB) {
  13.         try {
  14.             $this->conn = new PDO(
  15.                     'mysql:host=$op_cdb->datesDb->config["db_server"];$op_cdb->datesDb->config["db_name"]',
  16.                     $op_cdb->datesDb->config["db_user"],
  17.                     $op_cdb->datesDb->config["db_pass"]
  18.                     );
  19.  
  20.         } catch (PDOException $e) {
  21.             print "Erro!: " . $e->getMessage() . "<br/>";
  22.             die();
  23.         }
  24.     }
  25. }
  26.  ?>
  27.  
  28. #CLASSE CONFIG
  29. <?php
  30.  
  31. /**
  32.  @package OnePainel
  33.  @version 1.0
  34.  @author x[C]oder <contato@thebigxcoder.net>
  35.  */
  36.  
  37.  
  38. class OP_Config{
  39.  
  40.     public $config = array();
  41.     public $path   = array();
  42.  
  43.     public function datesDb($config) {
  44.         $this->config['db_server'] = "localhost";
  45.         $this->config['db_name']   = $_POST['db_name'];
  46.         $this->config['db_user']   = "root";
  47.         $this->config['db_pass']   = "";
  48.     }
  49.  
  50.     public function paths($path) {
  51.         $this->path['base_url'] = "http://localhost/projects/OnePanel";
  52.         $this->path['modules'] = "/model/modules";
  53.         $this->path['config'] = "/config";
  54.         $this->path['install'] = "/install";
  55.         $this->path['sql'] = "/sql";
  56.         $this->path['adm'] = "/adm";
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement