Exemple #1
0
    protected function maintenance()
    {
        $rows = $this->db->rows('select identity, bt.reason, b.expire
			from ban b
				left join ban_type bt on b.type_id_ = bt.id
			where (b.expire >= ' . $this->db->quote(new Time()) . ' or expire is null)');
        $identityBans = Arrays::compileSubsOnKey($rows, 'identity');
        foreach ($identityBans as $identity => $bans) {
            $putBans = array();
            foreach ($bans as $ban) {
                $putBans[] = Arrays::extract(array('reason', 'expire'), $ban);
            }
            Cache::set('bans-' . $identity, serialize($putBans));
        }
    }
Exemple #2
0
 function update()
 {
     if ($this->validate()) {
         $this->update = Arrays::extract($this->usedColumns, $this->control->in, $x = null, false);
         unset($this->update['id']);
         $this->lt->update = $this->update;
         Db::update($this->lt->model['table'], $this->update, $this->control->id);
         return true;
     }
 }
Exemple #3
0
 /**
 @note	insert ignore and insert update do not return a row id, so, if the id is not provided and the matchKeys are not provided, may not return row id
 @return will attempt to get row id, otherwise will return count of affected rows
 */
 protected function into($type, $table, $kvA, $update = '', $matchKeys = null)
 {
     $res = $this->query($type . ' INTO ' . $this->quoteIdentity($table) . $this->kvf($kvA) . $update);
     if ($this->under->lastInsertId()) {
         return $this->under->lastInsertId();
     } elseif ($kvA['id']) {
         return $kvA['id'];
     } elseif ($matchKeys) {
         $matchKva = Arrays::extract($matchKeys, $kvA);
         return $this->row($table, $matchKva, 'id');
     } else {
         return $res->rowCount();
     }
 }