Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:10:12+00:00 2026-06-10T18:10:12+00:00

I want to extend this class (which I downloaded) to suit my own needs.

  • 0

I want to extend this class (which I downloaded) to suit my own needs. When I run call this class I get an error complaining that there is an unexpected = in the constructor.

define("HIT_OLD_AFTER_SECONDS", 4 * 7 * 24 * 3600);
class PHPCount extends DatabaseObject {

    protected static $table_name = "hits";
    protected static $db_fields = array('pageid','isunique', 'hitcount','english_id');
    public $pageid;
    public $isunique;
    public $hitcount;
    public $english_id;
    public static $article_id;

    function __construct(){
        return  PHPCount::article_id = PHPCount::get_article_id();
    }
    public static function set_article_id($articleid){
        PHPCount::article_id = $articleid;
    }
    public static function get_article_id(){
        return PHPCount::article_id;
    }
    public static function AddHit($pageID, $visitorID){

        HitTest::Cleanup();
        self::CreateCountsIfNotPresent($pageID);
        if(HitTest::UniqueHit($pageID, $visitorID)){
            self::CountHit($pageID, true);
            HitTest::LogHit($pageID, $visitorID);
        }
        self::CountHit($pageID, false);
    }

    /*
     * Returns (int) the amount of hits a page has
     * $pageID - the page identifier
     * $unique - true if you want unique hit count
     */
    public static function GetHits($pageID, $unique = false){
        global $database;
        self::CreateCountsIfNotPresent($pageID);
        $pageID = $database->escape_value($pageID);
        $unique = $unique ? '1' : '0';
        $q  = "SELECT hitcount FROM hits WHERE ";
        $q .= get_article_id()=$pageID;
        $q .=" AND isunique={$unique}";
        $getHitCount = static::find_by_sql($q);
        if(sizeof($getHitCount) >= 1){
            foreach($getHitCount as $hit){
                return (int)$hit->hitcount;
            }
        }else{
            die("Fatal: Missing hit count from database!");
        }
    }

    /*
     * Returns the total amount of hits to the entire website
     * When $unique is FALSE, it returns the sum of all non-unique hit counts
     * for every page. When $unique is TRUE, it returns the sum of all unique
     * hit counts for every page, so the value that's returned IS NOT the 
     * amount of site-wide unique hits, it is the sum of each page's unique
     * hit count.
     */
    public static function GetTotalHits($unique = false){
        //global $phpcount_con;
        $total = 0;
        $unique = $unique ? '1' : '0';
        $q = "SELECT hitcount FROM hits WHERE isunique={$unique}";
        $count = static::find_by_sql($q);
        foreach($count as $hit){
            $total += (int)$hit->hitcount;
        }
        return $total;
    }

    private static function CountHit($pageID, $unique){
        global $database;
        $unique = $unique ? '1' : '0';
        $safeID = $database->escape_value($pageID);
        $q ="UPDATE hits SET hitcount = hitcount + 1 WHERE ";
        $q .=get_article_id()=$safeID;
        $q .=" AND isunique={$unique}";
        mysqli_query($database->connection,$q);
    }

    private static function CreateCountsIfNotPresent($pageID){
        global $database;
        $pageID = $database->escape_value($pageID);
        $q = "SELECT pageid FROM hits WHERE ";
        $q .=get_article_id()=$pageID;
        $q .=" AND isunique='0'";
        $createCount = static::find_by_sql($q);
        if($q === false || sizeof($createCount) < 1){
            $sql ="INSERT INTO hits(";
            $sql .=get_article_id();
            $sql .=", isunique, hitcount) VALUES(";
            $sql .=$pageID;
            $sql .=", '0', '0')";
            mysqli_query($database->connection,$sql);
        }

        //check unique row
        $q ="SELECT "get_article_id();
        $q .=" FROM hits WHERE ";
        $q .=get_article_id()=$pageID;
        $q .=" AND isunique='1'";
        $createCount = static::find_by_sql($q);
        if($q === false || sizeof($createCount) < 1){
            $sql ="INSERT INTO hits (";
            $sql .=get_article_id();
            $sql .=", isunique, hitcount) VALUES('$pageID', '1', '0')"
            mysqli_query($database->connection,$sql);
            echo mysqli_error($database->connection);
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:10:14+00:00Added an answer on June 10, 2026 at 6:10 pm

    Access to static class variables require a $-sign like here:

    PHPCount::$article_id 
    

    Thus, at least these methods need to be changed.

    // I'd propose to pass the article ID as a parameter here
    function __construct( $theArticleID ){
        PHPCount::$article_id = $theArticleID;         
    }
    public static function set_article_id($articleid){
       PHPCount::$article_id = $articleid;
    }
    public static function get_article_id(){
       return PHPCount::$article_id;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hei. the language is java. i want to extend this class which the constructor
So I have this class which extends an activity. But I want to draw
Folks I have a sealed class as follows. I want to extend this sealed
I want to extend RuntimeException to create this specific exception: class CompileLinkException extends RuntimeException
This the model that I want to create using json file Ext.define('Users', { extend:
I want to extend the IEnumerable class but only for types that can be
I have a class PlaylistTrack that I want to extend class Song. When I
I have a class named MyClass and I want this class to extend Graphics2D
I have a class from an external library that I want to extend with
I've got a class which overrides equals() and I want to see where this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.