Пример #1
0
 public function setNewServer($host, $user, $password, $database, $faild = self::EXCEPTION_FAILD_MODE)
 {
     //$this->server=null;
     //
     if ($host == "" and $user == "" and $database == "") {
         throw new DatabaseArgumentsException();
     } else {
         Database::$server = mysqli_connect($host, $user, $password, $database);
         //
         if (!Database::$server) {
             if ($faild == 2 && Config::get('panel.configured')) {
                 throw new DatabaseConnectionException();
             } else {
                 if ($faild == 1) {
                     \Errors::r_db();
                 }
             }
         }
         //
         mysqli_query(Database::$server, "SET NAMES " . Config::get("database.charset"));
         //
         Database::$serverData = ['host' => $host, "username" => $user, "password" => $password, "database" => $database];
         //
         //
         return Database::$server;
     }
 }
Пример #2
0
 /**
  * Format the message to show
  */
 public function show($process)
 {
     if ($process) {
         $this->info("The seeder is executed");
     } else {
         $this->error("There is an error" . Database::execErr());
     }
 }
 /**
  * Format the message to show
  */
 public function show($process)
 {
     if ($process) {
         $this->info("The schema is restored");
     } else {
         $this->error("There is an error " . Database::execErr());
     }
 }
Пример #4
0
 public function getAll()
 {
     return Database::read('select * from ' . $this->DatabaseTableName());
 }
Пример #5
0
 public static function exec_cos()
 {
     $Root = "../";
     $r = glob("../app/schemas/*.php");
     $r2 = array();
     $r2 = array();
     foreach ($r as $value) {
         $temp1 = explode("schemas/", $value);
         $temp2 = explode("_", $temp1[1]);
         $temp3 = explode(".", $temp2[1]);
         $ex = $temp3[0];
         //
         if ($ex == $_POST['exec_cos_migrate_select']) {
             $r2[] = $ex;
             $r3[] = $temp2[0];
         }
     }
     $v = "";
     $full_name = "";
     //
     if (count($r2) > 1) {
         for ($i = 1; $i < count($r2); $i++) {
             error_log($r3[$i] . '*/*' . $r3[$i - 1]);
             if ($r3[$i] >= $r3[$i - 1]) {
                 $v = "../app/schemas/" . $r3[$i] . "_" . $r2[$i] . ".php";
                 $full_name = $r3[$i] . "_" . $r2[$i];
             }
         }
     } else {
         $v = "../app/schemas/" . $r3[0] . "_" . $r2[0] . ".php";
         $full_name = $r3[0] . "_" . $r2[0];
     }
     try {
         include_once $v;
         if (up()) {
             Migration::updateRegister($full_name, "exec", $Root, '');
             echo "Schéma executé";
         } else {
             echo Database::execErr();
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Пример #6
0
 public static function remove($nom, $colmuns)
 {
     $name = self::tableName($nom);
     //
     self::$main_sql = "alter table " . $name . " ";
     //
     if (is_array($colmuns)) {
         // foreach ($colmuns as $value) {
         for ($i = 0; $i < count($colmuns); $i++) {
             if ($i == count($colmuns) - 1) {
                 self::$main_sql .= " drop " . $colmuns[$i];
             } else {
                 self::$main_sql .= " drop " . $colmuns[$i] . ",";
             }
         }
     } else {
         self::$main_sql .= " drop " . $colmuns;
     }
     //
     return Database::exec(self::$main_sql);
 }
Пример #7
0
 /**
  * To count rows by where clause
  *
  * @param $where (string) : the where clause
  **/
 public static function count($where)
 {
     $self = self::instance();
     $rows = new ModelArray();
     //
     $sql = "select count(*) as cnt from " . $self->DBtable . " where {$where} ";
     $data = Database::read($sql, 1);
     //
     return $data[0]['cnt'];
 }
Пример #8
0
 /**
  * Init Framework classes
  */
 protected static function ini()
 {
     Alias::ini(self::$root);
     Sys::ini();
     Url::ini();
     Path::ini();
     Template::run();
     Faker::ini();
     Links::ini();
     Errors::ini(self::$root);
     License::ini(self::$page);
     //langues
     Lang::setReplaceBlankTranslationBy(Lang::REPLACE_BY_BLANK);
     Lang::setReplaceNonExistingTranslationBy(Lang::REPLACE_BY_KEY_TRANSLATE_ME);
     Lang::initLanguage();
     Database::ini();
     Auth::ini();
     Plugins::ini();
     Widgets::ini();
 }
Пример #9
0
 public function paginate($RowsPerPage)
 {
     // count data
     $sql = "select count(*) as nbRows from " . $this->name;
     $var = Database::read($sql);
     $this->RowsPerPage = $RowsPerPage;
     $this->nbRows = $var[0]['nbRows'];
     $this->nbPages = ceil($this->nbRows / $RowsPerPage);
     //if isset get
     $this->CurrentPage = 1;
     if (isset($_GET[Config::get('view.pagination_param')]) && !empty($_GET[Config::get('view.pagination_param')])) {
         if ($_GET[Config::get('view.pagination_param')] > 0 && $_GET[Config::get('view.pagination_param')] <= $this->nbPages) {
             $this->CurrentPage = Res::get(Config::get('view.pagination_param'));
         }
     }
     //get Data
     $r = array();
     $sql = "select * from " . $this->name . " Limit " . ($this->CurrentPage - 1) * $this->RowsPerPage . ",{$this->RowsPerPage}";
     $this->data = Database::read($sql);
     //
     return $this;
 }
Пример #10
0
 public static function check()
 {
     if (Session::existe('auths')) {
         return true;
     } else {
         if (Cookie::existe(Config::get('auth.rememeber_cookie'))) {
             $y = Database::countS('select * from ' . Config::get('auth.table') . ' where rememberToken="' . Cookie::get(Config::get('auth.rememeber_cookie')) . '"');
             if ($y == 1) {
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
 }