Exemple #1
0
 private function setDataBase()
 {
     if (empty($this->conn)) {
         $dbhost = app_importer_lib_Config::getInstance()->get_dbhost();
         $dbuser = app_importer_lib_Config::getInstance()->get_dbuser();
         $dbpassword = app_importer_lib_Config::getInstance()->get_dbpassword();
         $dbname = app_importer_lib_Config::getInstance()->get_dbname();
         $this->conn = NewADOConnection(app_importer_lib_Config::getInstance()->get_dbdriver());
         $this->conn->Connect($dbhost, $dbuser, $dbpassword, $dbname);
         $this->conn->EXECUTE("set names 'utf8'");
         $this->conn->debug = app_importer_lib_Config::getInstance()->get_dbdebug();
     }
 }
Exemple #2
0
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new self();
     }
     self::$instance->dbhost = "localhost";
     self::$instance->dbuser = "******";
     self::$instance->dbpassword = "******";
     self::$instance->dbname = "cmsptmp";
     self::$instance->dbdebug = false;
     self::$instance->dbdriver = 'mysqli';
     self::$instance->timezone = 'America/Sao_Paulo';
     date_default_timezone_set(self::$instance->timezone);
     return self::$instance;
 }
Exemple #3
0
 public static function fixData($str)
 {
     $str = (string) $str;
     $str = trim($str);
     $str = empty($str) ? "0000-00-00" : $str;
     $str = str_replace("/", "-", $str);
     $str = str_replace(",", "-", $str);
     $str = str_replace(".", "-", $str);
     $str = str_replace(" ", "-", $str);
     try {
         $date = DateTime::createFromFormat("Y-m-d", $str, new DateTimeZone(app_importer_lib_Config::getInstance()->get_timezone()));
     } catch (Exception $e) {
         echo "\n" . $e->getMessage() . "\n";
         $date = new DateTime('01-01-1800');
     }
     $str = $date->format('d/m/Y');
     return $str;
 }