kernel/private/classes/clusterfilehandlers/dfsbackends/mysqli.php
public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false )
    {
        if ( $fname )
            $fname .= "::_purgeByLike($like, $onlyExpired)";
        else
            $fname = "_purgeByLike($like, $onlyExpired)";

        // common query part used for both DELETE and SELECT
        $where = " WHERE name LIKE " . $this->_quote( $like, true );

        if ( $expiry !== false )
            $where .= " AND mtime < " . (int)$expiry;
        elseif ( $onlyExpired )
            $where .= " AND expired = 1";

        if ( $limit )
            $sqlLimit = " LIMIT $limit";
        else
            $sqlLimit = "";

        $this->_begin( $fname );

        // select query, in FOR UPDATE mode
        $selectSQL = "SELECT name FROM " . $this->dbTable( $like ) .
                     "{$where} {$sqlLimit} FOR UPDATE";
        if ( !$res = $this->_query( $selectSQL, $fname ) )
        {
            $this->_rollback( $fname );
            return $this->_fail( "Selecting file metadata by like statement $like failed" );
        }
        $resultCount = mysqli_num_rows( $res );

        // if there are no results, we can just return 0 and stop right here
        if ( $resultCount == 0 )
        {
            $this->_rollback( $fname );
            return 0;
        }
        // the candidate for purge are indexed in an array
        else
        {
            for ( $i = 0; $i < $resultCount; $i++ )
            {
                $row = mysqli_fetch_assoc( $res );
                $files[] = $row['name'];
            }
        }

        // delete query
        $deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " {$where} {$sqlLimit}";
        if ( !$res = $this->_query( $deleteSQL, $fname ) )
        {
            $this->_rollback( $fname );
            return $this->_fail( "Purging file metadata by like statement $like failed" );
        }
        $deletedDBFiles = mysqli_affected_rows( $this->db );

        $commitResult = $this->_commit( $fname );
        if ( $commitResult === true || $commitResult === null )
        {
            $this->dfsbackend->delete( $files );

            return $deletedDBFiles;
        }

        return false;
    }
public function _purgeByLike( $like, $onlyExpired = false, $limit = 50, $expiry = false, $fname = false )
    {
        if ( $fname )
            $fname .= "::_purgeByLike($like, $onlyExpired)";
        else
            $fname = "_purgeByLike($like, $onlyExpired)";

        // common query part used for both DELETE and SELECT
        $where = " WHERE name LIKE " . $this->_quote( $like, true );

        if ( $expiry !== false )
            $where .= " AND mtime < " . (int)$expiry;
        elseif ( $onlyExpired )
            $where .= " AND expired = 1";

        if ( $limit )
            $sqlLimit = " LIMIT $limit";
        else
            $sqlLimit = "";

        $this->_begin( $fname );

        // select query, in FOR UPDATE mode
        $selectSQL = "SELECT name FROM " . $this->dbTable( $like ) .
                     "{$where} {$sqlLimit} FOR UPDATE";
        if ( !$res = $this->_query( $selectSQL, $fname ) )
        {
            $this->_rollback( $fname );
            return $this->_fail( "Selecting file metadata by like statement $like failed" );
        }
        $resultCount = mysqli_num_rows( $res );

        // if there are no results, we can just return 0 and stop right here
        if ( $resultCount == 0 )
        {
            $this->_rollback( $fname );
            return 0;
        }
        // the candidate for purge are indexed in an array
        else
        {
            for ( $i = 0; $i < $resultCount; $i++ )
            {
                $row = mysqli_fetch_assoc( $res );
                $files[] = $row['name'];
            }
        }

        // delete query
        $deleteSQL = "DELETE FROM " . $this->dbTable( $like ) . " {$where} {$sqlLimit}";
        if ( !$res = $this->_query( $deleteSQL, $fname ) )
        {
            $this->_rollback( $fname );
            return $this->_fail( "Purging file metadata by like statement $like failed" );
        }
        $deletedDBFiles = mysqli_affected_rows( $this->db );

        $commitResult = $this->_commit( $fname );
        if ( $commitResult === true || $commitResult === null )
        {
            $this->dfsbackend->delete( $files );

            return $deletedDBFiles;
        }

        return false;
    }
public function _purgeByLike ( $ like , $ onlyExpired = false , $ limit = 50 , $ expiry = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_purgeByLike($like, $onlyExpired)" ; else $ fname = "_purgeByLike($like, $onlyExpired)" ; // common query part used for both DELETE and SELECT $ where = " WHERE name LIKE " . $ this -> _quote ( $ like , true ) ; if ( $ expiry !== false ) $ where .= " AND mtime < " . ( int ) $ expiry ; elseif ( $ onlyExpired ) $ where .= " AND expired = 1" ; if ( $ limit ) $ sqlLimit = " LIMIT $limit" ; else $ sqlLimit = "" ; $ this -> _begin ( $ fname ) ; // select query, in FOR UPDATE mode $ selectSQL = "SELECT name FROM " . $ this -> dbTable ( $ like ) . "{$where} {$sqlLimit} FOR UPDATE" ; if ( ! $ res = $ this -> _query ( $ selectSQL , $ fname ) ) { $ this -> _rollback ( $ fname ) ; return $ this -> _fail ( "Selecting file metadata by like statement $like failed" ) ; } $ resultCount = mysqli_num_rows ( $ res ) ; // if there are no results, we can just return 0 and stop right here if ( $ resultCount == 0 ) { $ this -> _rollback ( $ fname ) ; return 0 ; } // the candidate for purge are indexed in an array else { for ( $ i = 0 ; $ i < $ resultCount ; $ i ++ ) { $ row = mysqli_fetch_assoc ( $ res ) ; $ files [ ] = $ row [ 'name' ] ; } } // delete query $ deleteSQL = "DELETE FROM " . $ this -> dbTable ( $ like ) . " {$where} {$sqlLimit}" ; if ( ! $ res = $ this -> _query ( $ deleteSQL , $ fname ) ) { $ this -> _rollback ( $ fname ) ; return $ this -> _fail ( "Purging file metadata by like statement $like failed" ) ; } $ deletedDBFiles = mysqli_affected_rows ( $ this -> db ) ; $ commitResult = $ this -> _commit ( $ fname ) ; if ( $ commitResult === true || $ commitResult === null ) { $ this -> dfsbackend -> delete ( $ files ) ; return $ deletedDBFiles ; } return false ; }
Purges meta-data and file-data for files matching a pattern using a SQL
LIKE syntax.

@param string $like SQL LIKE string applied to ezdfsfile.name to look for files to purge
@param bool $onlyExpired Only purge expired files (ezdfsfile.expired = 1)
@param int $limit Maximum number of items to purge in one call
@param bool|int $expiry Timestamp used to limit deleted files: only files older than this date will be deleted
@param string|bool $fname Optional caller name for debugging

@see _purge

@return bool|int false if it fails, number of affected rows otherwise
Purges meta - data and file - data for files matching a pattern using a SQL LIKE syntax .