>> YANA 4 PHP Framework >> Docs For Class Counter

Class Counter

Description

counter wrapper

This class implements persistent counters - optional with IP checking - for various purposes: e.g. visitor counts, statistics, polls.

  • access: public

Located in /includes/class_counter.php

Object
   |
   --Counter
Method Summary
  • Counter Counter ([string $filename = ""], [int $use_ip = YANA_COUNTER_USE_IP])
  • int count (string $id, [string $info = ""], [int $ammount = 1])
  • string equals (object $another_object)
  • array get ([string $id = "*"])
  • mixed getCount ([string $id = "*"])
  • mixed getInfo ([string $id = "*"])

Methods

create a new instance
Counter Counter (
[string $filename = ""], [int $use_ip = YANA_COUNTER_USE_IP]
)
List of parameters:
Name Type Description
$filename string (optional)
$use_ip int (optional) default = YANA_COUNTER_USE_IP
Description:

Use the $use_ip parameter with the setting YANA_COUNTER_USE_IP to create a counter with IP checking (does'nt change on reload) or with the setting YANA_COUNTER_IGNORE_IP to create a counter without IP checking (always changes when an update is called).

Increment/Decrement counter
int count (
string $id, [string $info = ""], [int $ammount = 1]
)
List of parameters:
Name Type Description
$id string
$info string (optional)
$ammount int (optional) default = 1
Description:

Adds $ammount (defaults to +1) to the counter $id and sets the counter description (the 'info' field) to $info (defaults to "").

Note: as you might already have guessed, using a negative value for $ammount decrements the counter.

  • access: public
compare with another object
string equals (
object $another_object
)
List of parameters:
Name Type Description
$another_object object
Description:

Returns bool(true) if this object and $another_object are equal and bool(false) otherwise.

Two instances are considered equal if and only if they are both objects of the same class, they both refer to the same filesystem resource and use the same IP settings.

  • access: public

Redefinition of: Object::equals()

get counter
array get (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string (optional)
Description:

Returns the current counter settings as:

 Array(
    'COUNT' => int
    'INFO'  => string
 )

Note: you may use the wildcard '*' to get all counters as an associative, multidimensional array:

 Array(
    ID1 => Array(
        'COUNT' => int
        'INFO'  => string
    )
    ID2 => Array(
        'COUNT' => int
        'INFO'  => string
    )
    ...
 )

  • access: public
get counter value
mixed getCount (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string (optional)
Description:

This function returns the current value of counter $key.

Note: you may use the wildcard '*' to get an associative array for all values:

 Array(
    ID1 => int
    ID2 => int
    ...
 )

  • access: public
get counter info
mixed getInfo (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string (optional)
Description:

The 'info' field is an optional text value, that describes the counter.

This function returns the current description of counter $key.

Note: you may use the wildcard '*' to get an associative array for all counters:

 Array(
    ID1 => string
    ID2 => string
    ...
 )

  • access: public
inherited from base classes

Inherited From Object

Documentation generated on Wed, 22 Nov 2006 20:19:03 +0100 by phpDocumentor 1.3.1

yana author: Thomas MeyerHomepage: www.all-community.de/pub