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;
 }
Beispiel #2
0
 public static function rollback($bundle)
 {
     $Root = Process::root;
     $r = glob($Root . "app/bundles/{$bundle}/schemas/*.php");
     //
     $pieces = array();
     $pieces1 = array();
     $pieces2 = array();
     $full_names = array();
     //
     $time = "";
     $name = "";
     //
     $f = array();
     foreach ($r as $key) {
         $pieces = explode("app/bundles/{$bundle}/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];
     //
     include_once $link;
     if (down()) {
         if (Schema::existe(Config::get('database.migration'))) {
             self::updateRow('rolledback', $name, $time);
         }
         $full_names = $time . "_" . $name;
         Migration::updateRegister($full_names, "rollback", $Root, $bundle);
         return true;
     } else {
         false;
     }
 }