TokyoTyrant
TokyoTyrant::connect
TokyoTyrant
PHP Manual

# TokyoTyrant::add

(PECL tokyo_tyrant >= Unknown)

TokyoTyrant::add — Adds to a numeric key

### Opis

public number TokyoTyrant::add ( string `$key` , number `$increment` [, string `$type` ] )

Adds to a int or double value. This increments the value by the given amount and returns the new value. If the key does not exist a new key is created with initial value of the increment parameter.

### Parametry

`key`

  The string key

`increment`

  The amount to increment

`type`

  `TokyoTyrant::RDB_RECINT` or `TokyoTyrant::RDB_RECDBL` constant. If this parameter is omitted the type is guessed from the `increment` parameters type.

### Zwracane wartości

Returns the new value on success

### Przykłady

Przykład #1 TokyoTyrant::add example

`<?php
$tt = new TokyoTyrant("localhost", TokyoTyrant::RDBDEF_PORT);
/* Adds integer 3 to key and creates a new key */
$tt->add("test", 3);
/* String value is converted to double */
echo $tt->add("test", "3.5", TokyoTyrant::RDB_RECDBL);
?>`

Powyższy przykład wyświetli coś podobnego do:

    6.5

### Zobacz też:

- TokyoTyrant::put - Puts values
- TokyoTyrant::putcat - Concatenates to a record
- TokyoTyrant::putkeep - Puts a record

TokyoTyrant
TokyoTyrant::connect
TokyoTyrant
PHP Manual