Пример #1
0
 /**
  * (non-PHPdoc)
  * @see SessionHandlerInterface::gc()
  */
 public function gc($maxlifetime)
 {
     $delete = new Delete($this->config['table']);
     $timestamp = time() - $maxlifetime;
     if ($delete->where('time', '<', $timestamp)->exec($this->config['connection']) === false) {
         Log::error("Session GC: Error deleting session record from database that are older then maxlifetime={$maxlifetime} (older then timestamp {$timestamp})");
         return false;
     }
     return true;
 }
Пример #2
0
 /**
  * Delete one or more records from the table defined in this model. If you
  * pass array, then array must contain field names and values that will be
  * used in WHERE statement. If you pass primitive value, method will treat
  * that as passed value for primary key field.
  * 
  * @param mixed $where
  * @return integer How many records is deleted
  * @example User::delete(1);
  * @example User::delete(array('group_id' => 5, 'parent_id' => 10));
  * @example User::delete(array('parent_id' => 10, array('time', '>', '2013-08-01 00:00:00')))
  * @return int number of affected rows
  * @link http://koldy.net/docs/database/models#delete
  */
 public static function delete($where)
 {
     $delete = new Delete(static::getTableName());
     if ($where instanceof Where) {
         $delete->where($where);
     } else {
         if (is_array($where)) {
             foreach ($where as $field => $value) {
                 $delete->where($field, $value);
             }
         } else {
             if (!is_array(static::$primaryKey) && (is_numeric($where) || is_string($where))) {
                 $delete->where(static::$primaryKey, $where);
             }
         }
     }
     return $delete->exec(static::$connection);
 }
Пример #3
0
 /**
  * (non-PHPdoc)
  * @see \Koldy\Cache\Driver\AbstractDriver::deleteOld()
  */
 public function deleteOld($olderThenSeconds = null)
 {
     if ($olderThenSeconds === null) {
         $olderThenSeconds = $this->defaultDuration;
     }
     $delete = new Delete($this->config['table']);
     $delete->setConnection($this->config['connection'])->where('expires_at', '<=', time())->exec();
 }