src/Mvc/Listener/Limit/Storage/Db.php
public function check($ip, Limit $limit)
    {
        $this->assertReady();
        
        if ($this->cleanOnCheck) {
            $this->clean();
        }
        
        $sql = sprintf("SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND",
            $this->dbAdapter->platform->quoteIdentifier($this->table),
            $this->dbAdapter->platform->quoteIdentifier($this->ipColumn),
            $this->dbAdapter->platform->quoteIdentifier($this->typeColumn),
            $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn),
            $limit->getInterval()->toSeconds());
        
        $parameters = array(
            'ip' => $ip,
            'type' => $limit->getName(),
        );
        
        $result = $this->dbAdapter->query($sql, $parameters);
        $count = $result->current()->count;
        return $count >= $limit->getLimit();
    }
public function check($ip, Limit $limit)
    {
        $this->assertReady();
        
        if ($this->cleanOnCheck) {
            $this->clean();
        }
        
        $sql = sprintf("SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND",
            $this->dbAdapter->platform->quoteIdentifier($this->table),
            $this->dbAdapter->platform->quoteIdentifier($this->ipColumn),
            $this->dbAdapter->platform->quoteIdentifier($this->typeColumn),
            $this->dbAdapter->platform->quoteIdentifier($this->timestampColumn),
            $limit->getInterval()->toSeconds());
        
        $parameters = array(
            'ip' => $ip,
            'type' => $limit->getName(),
        );
        
        $result = $this->dbAdapter->query($sql, $parameters);
        $count = $result->current()->count;
        return $count >= $limit->getLimit();
    }
public function check ( $ ip , Limit $ limit ) { $ this -> assertReady ( ) ; if ( $ this -> cleanOnCheck ) { $ this -> clean ( ) ; } $ sql = sprintf ( "SELECT count(*) as count FROM %s WHERE %s=:ip AND %s=:type AND %s >= NOW() - INTERVAL %d SECOND" , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> table ) , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> ipColumn ) , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> typeColumn ) , $ this -> dbAdapter -> platform -> quoteIdentifier ( $ this -> timestampColumn ) , $ limit -> getInterval ( ) -> toSeconds ( ) ) ; $ parameters = array ( 'ip' => $ ip , 'type' => $ limit -> getName ( ) , ) ; $ result = $ this -> dbAdapter -> query ( $ sql , $ parameters ) ; $ count = $ result -> current ( ) -> count ; return $ count >= $ limit -> getLimit ( ) ; }
Check if the number or records in the database exceeds the set limit

@see \Spork\Mvc\Listener\Limit\Storage\StorageInterface::check()
@param string $ip
@param Limit $limit
@return boolean
Check if the number or records in the database exceeds the set limit