Exemple #1
0
 /**
  * Garbage collector.
  *
  * @param   int      $maxLifetime  Lifetime in secods
  * 
  * @return  boolean
  */
 public function gc($maxLifetime)
 {
     try {
         return (bool) $this->db->from($this->table)->where($this->columns['expires'])->lt(time())->delete();
     } catch (PDOException $e) {
         return false;
     }
 }
Exemple #2
0
 /**
  * Deletes this model
  *
  * @return  boolean
  */
 public function delete()
 {
     if ($this->deleted) {
         throw new RuntimeException('This record was deleted');
     }
     if (!isset($this->columns[$this->primaryKey])) {
         throw new RuntimeException('This is a new record that was not saved yet');
     }
     $result = $this->database->from($this->getTable())->where($this->primaryKey)->is($this->columns[$this->primaryKey])->delete();
     $this->deleted = true;
     return (bool) $result;
 }