models/log/Login.php
protected function deleteExtraRecords()
    {
        try {
            $limit = (int)($this->limitMax);
        } catch (\Exception $ex) {
            Yii::error($ex->getMessage(), __METHOD__);
            return 0;
        }
        $host = $this->host;
         /* @var $host \rhosocial\user\User */
        $count = static::find()->createdBy($host)->count();
        Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
        if ($count > $limit) {
            foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
                /* @var $login static */
                $result = $login->delete();
                if (YII_ENV_DEV) {
                    Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
                }
            }
        }
        return $count - $limit;
    }
protected function deleteExtraRecords()
    {
        try {
            $limit = (int)($this->limitMax);
        } catch (\Exception $ex) {
            Yii::error($ex->getMessage(), __METHOD__);
            return 0;
        }
        $host = $this->host;
         /* @var $host \rhosocial\user\User */
        $count = static::find()->createdBy($host)->count();
        Yii::info($host->getReadableGUID() . " has $count login logs.", __METHOD__);
        if ($count > $limit) {
            foreach (static::find()->createdBy($host)->orderByCreatedAt()->limit($count - $limit)->all() as $login) {
                /* @var $login static */
                $result = $login->delete();
                if (YII_ENV_DEV) {
                    Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
                }
            }
        }
        return $count - $limit;
    }
protected function deleteExtraRecords ( ) { try { $ limit = ( int ) ( $ this -> limitMax ) ; } catch ( \ Exception $ ex ) { Yii :: error ( $ ex -> getMessage ( ) , __METHOD__ ) ; return 0 ; } $ host = $ this -> host ; /* @var $host \rhosocial\user\User */ $ count = static :: find ( ) -> createdBy ( $ host ) -> count ( ) ; Yii :: info ( $ host -> getReadableGUID ( ) . " has $count login logs." , __METHOD__ ) ; if ( $ count > $ limit ) { foreach ( static :: find ( ) -> createdBy ( $ host ) -> orderByCreatedAt ( ) -> limit ( $ count - $ limit ) -> all ( ) as $ login ) { /* @var $login static */ $ result = $ login -> delete ( ) ; if ( YII_ENV_DEV ) { Yii :: info ( $ host -> getReadableGUID ( ) . ": ($result) login record created at (" . $ login -> getCreatedAt ( ) . ") was just deleted." , __METHOD__ ) ; } } } return $ count - $ limit ; }
Delete extra records.
@return integer The total of rows deleted.
Delete extra records .