Esempio n. 1
0
 public static function rollback()
 {
     $Root = "../";
     $r = glob("../app/schemas/*.php");
     //
     $pieces = array();
     $pieces1 = array();
     $pieces2 = array();
     $full_names = array();
     //
     $time = "";
     $name = "";
     //
     $f = array();
     foreach ($r as $key) {
         //echo $key."\n";
         $pieces = explode("app/schemas/", $key);
         $pieces1 = explode("_", $pieces[1]);
         $time = $pieces1[0];
         $p = explode(".", $pieces1[1]);
         $name = $p[0];
         $f[] = $pieces1[0];
         $pieces2[] = $pieces[1];
         //
         $full_names = $pieces1[0] . "_" . $name;
     }
     $mx = max($f);
     //
     $ind = 0;
     $i = 0;
     //
     foreach ($pieces2 as $value) {
         if (strpos($value, $mx) !== false) {
             $ind = $i;
         }
         $i++;
     }
     $link = $r[$ind];
     //
     try {
         include_once $link;
         if (down()) {
             if (Schema::existe(Config::get('database.migration'))) {
                 Database::exec("update " . Config::get('database.migration') . " set status_schema='rolledback' where name_schema='" . $name . "' and date_schema='" . $time . "'");
             }
             $full_names = $time . "_" . $name;
             Migration::updateRegister($full_names, "rollback", $Root);
             echo "Schéma annulé";
         } else {
             echo "Schema n'est pas annulé" . Database::execErr();
         }
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Esempio n. 2
0
 public function clearOld()
 {
     $all = $this->getAll();
     //
     foreach ($all as $rows) {
         $life = $rows['life'];
         if (time() > $life) {
             Schema::table($this->DatabaseTableName())->delete("name='" . $rows['name'] . "'");
         }
     }
     return true;
 }