Location: PHPKode > scripts > Access Pattern Counter > access-pattern-counter/class.counterUser.php
<?php

//
// Class: CounterUser
// Table: counterUser
// Database: counter
/*
+------------+---------------+------+-----+---------+----------------+
| Field      | Type          | Null | Key | Default | Extra          |
+------------+---------------+------+-----+---------+----------------+
| id         | int(11)       |      | PRI | NULL    | auto_increment |
| counterId  | int(11)       | YES  | MUL | NULL    |                |
| remoteAddr | varchar(255)  | YES  |     | NULL    |                |
| timestamp  | timestamp(14) | YES  |     | NULL    |                |
| repeat     | int(11)       | YES  |     | 0       |                |
+------------+---------------+------+-----+---------+----------------+
*/
// Generated by buildClass.php, written by Dick Munroe (hide@address.com)
//

include_once("SQLData.php") ;

class CounterUser extends SQLData
{

    //
    // Private (or constant) varibles.
    //
    
    var $m__tableName = 'counterUser' ;

    //
    // Constructor
    //
    
    function CounterUser($_counterId,
		     $_remoteAddr,
		     $_dataBase,
                     $_host="localhost",
                     $_login="",
                     $_password="")
    {
        $this->SQLData($this->m__tableName, $_dataBase, $_host, $_login, $_password) ;

        $this->select("where remoteAddr = '" . $this->escape_string($_remoteAddr) . 
		      "' and counterId = '" . $this->escape_string($_counterId) . "'") ; 
        
        if ($this->eof())
        {
	    $this->setCounterId($_counterId) ;
            $this->setRemoteAddr($_remoteAddr) ;
            $this->setTimestamp('00000000000000') ;
            
            $this->insert() ;

	    $this->initId($this->fetchLastInsertId()) ;
        }
    }

    //
    // Accessor Functions
    //
     
    function setId($theValue)
    {
        $this->set('id', $theValue) ;
    }
    
    function getId()
    {
        return $this->get('id') ;
    }
    
    function initId($theValue)
    {
        $this->init('id', $theValue) ;
    }
    
    function setCounterId($theValue)
    {
        $this->set('counterId', $theValue) ;
    }
    
    function getCounterId()
    {
        return $this->get('counterId') ;
    }
    
    function initCounterId($theValue)
    {
        $this->init('counterId', $theValue) ;
    }
    
    function setRemoteAddr($theValue)
    {
        $this->set('remoteAddr', $theValue) ;
    }
    
    function getRemoteAddr()
    {
        return $this->get('remoteAddr') ;
    }
    
    function initRemoteAddr($theValue)
    {
        $this->init('remoteAddr', $theValue) ;
    }
    
    function setTimestamp($theValue)
    {
        $this->set('timestamp', $theValue) ;
    }
    
    function getTimestamp()
    {
        return $this->get('timestamp') ;
    }
    
    function initTimestamp($theValue)
    {
        $this->init('timestamp', $theValue) ;
    }
    
    function setRepeat($theValue)
    {
        $this->set('repeat', $theValue) ;
    }
    
    function getRepeat()
    {
        return $this->get('repeat') ;
    }
    
    function initRepeat($theValue)
    {
        $this->init('repeat', $theValue) ;
    }
    
    //
    // Debugging Functions
    //

    function print_r()
    {
        print("class " . get_class($this) . " ") ;
        parent::print_r() ;
    }
}

?>
Return current item: Access Pattern Counter