Book/tokyo-tyrant-Phpdoc专题
tokyo_tyrant
目录
- 简介
- 安装/配置
- 预定义常量
- 范例
- TokyoTyrant — The TokyoTyrant
class
- TokyoTyrant::add — Adds to a numeric key
- TokyoTyrant::connect — Connect to a database
- TokyoTyrant::connectUri — Connects to a database
- TokyoTyrant::__construct — Construct a new TokyoTyrant object
- TokyoTyrant::copy — Copies the database
- TokyoTyrant::ext — Execute a remote script
- TokyoTyrant::fwmKeys — Returns the forward matching keys
- TokyoTyrant::get — The get purpose
- TokyoTyrant::getIterator — Get an iterator
- TokyoTyrant::num — Number of records in the database
- TokyoTyrant::out — Removes records
- TokyoTyrant::put — Puts values
- TokyoTyrant::putCat — Concatenates to a record
- TokyoTyrant::putKeep — Puts a record
- TokyoTyrant::putNr — Puts value
- TokyoTyrant::putShl — Concatenates to a record
- TokyoTyrant::restore — Restore the database
- TokyoTyrant::setMaster — Set the replication master
- TokyoTyrant::size — Returns the size of the value
- TokyoTyrant::stat — Get statistics
- TokyoTyrant::sync — Synchronize the database
- TokyoTyrant::tune — Tunes connection values
- TokyoTyrant::vanish — Empties the database
- TokyoTyrantTable — The
TokyoTyrantTable class
- TokyoTyrantTable::add — Adds a record
- TokyoTyrantTable::genUid — Generate unique id
- TokyoTyrantTable::get — Get a row
- TokyoTyrantTable::getIterator — Get an iterator
- TokyoTyrantTable::getQuery — Get a query object
- TokyoTyrantTable::out — Remove records
- TokyoTyrantTable::put — Store a row
- TokyoTyrantTable::putCat — Concatenates to a row
- TokyoTyrantTable::putKeep — Put a new record
- TokyoTyrantTable::putNr — Puts value
- TokyoTyrantTable::putShl — Concatenates to a record
- TokyoTyrantTable::setIndex — Sets index
- TokyoTyrantQuery — The
TokyoTyrantQuery class
- TokyoTyrantQuery::addCond — Adds a condition to the query
- TokyoTyrantQuery::__construct — Construct a new query
- TokyoTyrantQuery::count — Counts records
- TokyoTyrantQuery::current — Returns the current element
- TokyoTyrantQuery::hint — Get the hint string of the query
- TokyoTyrantQuery::key — Returns the current key
- TokyoTyrantQuery::metaSearch — Retrieve records with multiple queries
- TokyoTyrantQuery::next — Moves the iterator to next entry
- TokyoTyrantQuery::out — Removes records based on query
- TokyoTyrantQuery::rewind — Rewinds the iterator
- TokyoTyrantQuery::search — Searches records
- TokyoTyrantQuery::setLimit — Limit results
- TokyoTyrantQuery::setOrder — Orders results
- TokyoTyrantQuery::valid — Checks the validity of current item
- TokyoTyrantIterator —
The TokyoTyrantIterator class
- TokyoTyrantIterator::__construct — Construct an iterator
- TokyoTyrantIterator::current — Get the current value
- TokyoTyrantIterator::key — Returns the current key
- TokyoTyrantIterator::next — Move to next key
- TokyoTyrantIterator::rewind — Rewinds the iterator
- TokyoTyrantIterator::valid — Rewinds the iterator
- TokyoTyrantException — The TokyoTyrantException class
tokyo_tyrant extension provides a wrapper for Tokyo Tyrant client libraries. The extension contains the normal key-value API and the table API.
"Tokyo Tyrant is a package of network interface to the DBM called Tokyo Cabinet. Though the DBM has high performance, you might bother in case that multiple processes share the same database, or remote processes access the database. Thus, Tokyo Tyrant is provided for concurrent and remote connections to Tokyo Cabinet. It is composed of the server process managing a database and its access library for client applications." --Tokyo Tyrant documentation
Tokyo Tyrant is written by Mikio Hirabayashi and is licensed under GNU Lesser General Public License.
安装/配置
目录
需求
Before using this extension Tokyo Cabinet and Tokyo Tyrant must be installed.
安装
安装此 PECL 扩展相关的信息可在手册中标题为 PECL 扩展的安装章节中找到。更多信息如新的发行版本、下载、源文件、 维护人员信息及变更日志等,都在此处: » https://pecl.php.net/package/tokyo_tyrant
Configure options
- --with-tokyo-tyrant[=DIR] DIR is the prefix to the Tokyo Tyrant installation
- --with-tokyo-cabinet-dir[=DIR] DIR is the prefix to the Tokyo Cabinet installation
- --disable-tokyo-tyrant-session Disable Tokyo Tyrant session handler support
Enabling the extension
The extension can be enabled by adding extension=tokyo_tyrant.so to the INI-configuration
Running Tokyo Tyrant for the session handler
ttserver -port 2000 -ext /path/to/expire.lua -extpc expire 30.0 '/tmp/sessions.tct#idx=ts:dec'
Note: expire.lua is included in the tokyo_tyrant extension source distribution
Configuring session handler
- tokyo_tyrant.session_salt="randomlongstring"
- session.save_handler=tokyo_tyrant
- session.save_path="tcp://hostname1:2000,tcp://hostname2:2000"
Note: It is important to make sure that tokyo_tyrant.session_salt matches on all servers.
How it works?
The session handler creates a session id like the following: 8b0e27a823fa4a6cf7246945b82c1d51-a5eadbbed1f2075952900628456bfd6830541629-0-5460
The parts from left to right:
- Session id - Generated session id
- Checksum - Checksum of session salt, session id, node id and primary key
- Node id - The id of the node where the session maps to
- Primary key - The primary key of the row where the session is stored
The checksum contains SHA1 sum of the node id, primary key, session id and the salt which is known only on the server side. This allows quick mapping of session id to node and primary key since there is no need to do an additional search. During session id regeneration only the parts 1 and 2 change but the mapping to the node and primary key stays constant.
In case some of the nodes fail tokyo_tyrant.allow_failover, tokyo_tyrant.fail_threshold and tokyo_tyrant.health_check_divisor INI-settings control the behavior during failover. If failover is allowed the session handler will map the session to a healthy node and creates a new empty session.
运行时配置
这些函数的行为受 php.ini
中的设置影响。
名字 | 默认 | 可修改范围 | 更新日志 |
---|---|---|---|
tokyo_tyrant.default_timeout | 2.0 | PHP_INI_ALL | |
tokyo_tyrant.session_salt | null |
PHP_INI_ALL | |
tokyo_tyrant.key_prefix | null |
PHP_INI_ALL | |
tokyo_tyrant.allow_failover | 1 | PHP_INI_ALL | |
tokyo_tyrant.fail_threshold | 5 | PHP_INI_ALL | |
tokyo_tyrant.health_check_divisor | 1000 | PHP_INI_ALL | |
tokyo_tyrant.php_expiration | 0 | PHP_INI_ALL |
这是配置指令的简短说明。
tokyo_tyrant.default_timeout
int
Default timeout when connecting to databases
tokyo_tyrant.session_salt
string
The secret that is used to salt session id
tokyo_tyrant.key_prefix
string
Prefix all keys with this string. The prefix is transparent to the
developer but helps making sure that keys won't collide if multiple
applications are using the same database.
tokyo_tyrant.allow_failover
int
Whether to allow session failover in case a server dies.
tokyo_tyrant.fail_threshold
int
How many read/write or connection failures is allowed before server is
marked as failed.
tokyo_tyrant.health_check_divisor
int
Defines the divisor for the health check probability. If there are
failed servers and the probability matches, the servers are health
checked and in case the server seems healthy, it will be added back to
the pool.
tokyo_tyrant.php_expiration
int
Whether to use built in session expiration mechanism or delegate the
expiration to a lua-script on the server-side.
资源类型
此扩展没有定义资源类型。
预定义常量
范例
Basic usage
示例 #1 Putting and getting a key-value pair
<?php
$tt = new TokyoTyrant("localhost");
$tt->put("key", "value");
echo $tt->get("key");
?>
以上例程会输出:
value
简介
The main Tokyo Tyrant class
类摘要
TokyoTyrant
class TokyoTyrant {
/* 常量 */
const int
TokyoTyrant::RDBDEF_PORT
= 1978 ;
const int
TokyoTyrant::RDBQC_STREQ
= 0 ;
const int
TokyoTyrant::RDBQC_STRINC
= 1 ;
const int
TokyoTyrant::RDBQC_STRBW
= 2 ;
const int
TokyoTyrant::RDBQC_STREW
= 3 ;
const int
TokyoTyrant::RDBQC_STRAND
= 4 ;
const int
TokyoTyrant::RDBQC_STROR
= 5 ;
const int
TokyoTyrant::RDBQC_STROREQ
= 6 ;
const int
TokyoTyrant::RDBQC_STRRX
= 7 ;
const int
TokyoTyrant::RDBQC_NUMEQ
= 8 ;
const int
TokyoTyrant::RDBQC_NUMGT
= 9 ;
const int
TokyoTyrant::RDBQC_NUMGE
= 10 ;
const int
TokyoTyrant::RDBQC_NUMLT
= 11 ;
const int
TokyoTyrant::RDBQC_NUMLE
= 12 ;
const int
TokyoTyrant::RDBQC_NUMBT
= 13 ;
const int
TokyoTyrant::RDBQC_NUMOREQ
= 14 ;
const int
TokyoTyrant::RDBQC_NEGATE
= 16777216
;
const int
TokyoTyrant::RDBQC_NOIDX
= 33554432
;
const int
TokyoTyrant::RDBQO_STRASC
= 0 ;
const int
TokyoTyrant::RDBQO_STRDESC
= 1 ;
const int
TokyoTyrant::RDBQO_NUMASC
= 2 ;
const int
TokyoTyrant::RDBQO_NUMDESC
= 3 ;
const int
TokyoTyrant::RDBIT_LEXICAL
= 0 ;
const int
TokyoTyrant::RDBIT_DECIMAL
= 1 ;
const int
TokyoTyrant::RDBIT_TOKEN
= 2 ;
const int
TokyoTyrant::RDBIT_QGRAM
= 3 ;
const int
TokyoTyrant::RDBIT_OPT
= 9998 ;
const int
TokyoTyrant::RDBIT_VOID
= 9999 ;
const int
TokyoTyrant::RDBIT_KEEP
= 16777216 ;
const int
TokyoTyrant::RDBQCFTS_PH
= 15 ;
const int
TokyoTyrant::RDBQCFTS_AND
= 16 ;
const int
TokyoTyrant::RDBQCFTS_OR
= 17 ;
const int
TokyoTyrant::RDBQCFTS_EX
= 18 ;
const int
TokyoTyrant::RDBXO_LCKREC
= 1 ;
const int
TokyoTyrant::RDBXOLCK_GLB
= 2 ;
const int
TokyoTyrant::RDBREC_INT
= 1 ;
const int
TokyoTyrant::RDBREC_DBL
= 2 ;
const int
TokyoTyrant::RDBMS_UNION
= 0 ;
const int
TokyoTyrant::RDBMS_ISECT
= 1 ;
const int
TokyoTyrant::RDBMS_DIFF
= 2 ;
const int
TokyoTyrant::RDBT_RECON
= 1 ;
/* 方法 */
public <span
class="type">intfloat <span
class="methodname">add ( <span
class="type">string $key
, <span
class="methodparam"><span
class="type">intfloat
$increment
[, <span
class="type">int $type
=
0 ] )
public <span
class="type">TokyoTyrant connect
( string
$host
[, <span
class="type">int $port
=
TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]] )
public <span
class="type">TokyoTyrant <span
class="methodname">connectUri ( <span
class="type">string $uri
)
public <span
class="methodname">__construct ([ <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]]] )
public <span
class="type">TokyoTyrant copy (
string
$path
)
public string
ext ( <span
class="type">string $name
, <span
class="methodparam">int $options
,
string $key
, string
$value
)
public array
fwmKeys ( <span
class="methodparam">string $prefix
,
int
$max_recs
)
public mixed
get ( <span
class="type">mixed $keys
)
public <span class="type">TokyoTyrantIterator <span class="methodname">getIterator ( <span class="methodparam">void )
public int <span class="methodname">num ( void )
public <span
class="type">TokyoTyrant out (
mixed $keys
)
public <span
class="type">TokyoTyrant put (
mixed $keys
[, string
$value
= NULL ] )
public <span
class="type">TokyoTyrant putCat (
mixed $keys
[, string
$value
] )
public <span
class="type">TokyoTyrant putKeep
( mixed
$keys
[, <span
class="type">string $value
] )
public <span
class="type">TokyoTyrant putNr (
mixed $keys
[, string
$value
= NULL ] )
public mixed
putShl ( <span
class="type">string $key
, <span
class="methodparam">string $value
,
int $width
)
public mixed
restore ( <span
class="methodparam">string $log_dir
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public mixed
setMaster ( <span
class="methodparam">string $host
,
int $port
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public int <span
class="methodname">size ( <span
class="type">string $key
)
public array stat ( <span class="methodparam">void )
public mixed sync ( <span class="methodparam">void )
public <span
class="type">TokyoTyrant tune (
float
$timeout
[, <span
class="type">int $options
=
TokyoTyrant::RDBT_RECON ] )
public mixed vanish ( <span class="methodparam">void )
}
预定义常量
TokyoTyrant Constants
TokyoTyrant::RDBDEF_PORT
The default port of the Tokyo Tyrant database
TokyoTyrant::RDBQC_STREQ
string is equal to
TokyoTyrant::RDBQC_STRINC
string is included in
TokyoTyrant::RDBQC_STRBW
string begins with
TokyoTyrant::RDBQC_STREW
string ends with
TokyoTyrant::RDBQC_STRAND
string includes all tokens in
TokyoTyrant::RDBQC_STROR
string includes at least one token in
TokyoTyrant::RDBQC_STROREQ
string is equal to at least one token in
TokyoTyrant::RDBQC_STRRX
string matches regular expressions of
TokyoTyrant::RDBQC_NUMEQ
number is equal to
TokyoTyrant::RDBQC_NUMGT
number is greater than
TokyoTyrant::RDBQC_NUMGE
number is greater than or equal to
TokyoTyrant::RDBQC_NUMLT
number is less than
TokyoTyrant::RDBQC_NUMLE
number is less than or equal to
TokyoTyrant::RDBQC_NUMBT
number is between two tokens of
TokyoTyrant::RDBQC_NUMOREQ
number is equal to at least one token in
TokyoTyrant::RDBQC_NEGATE
negation flag
TokyoTyrant::RDBQC_NOIDX
no index flag
TokyoTyrant::RDBQO_STRASC
string ascending
TokyoTyrant::RDBQO_STRDESC
string descending
TokyoTyrant::RDBQO_NUMASC
number ascending
TokyoTyrant::RDBQO_NUMDESC
number descending
TokyoTyrant::RDBIT_LEXICAL
lexical string
TokyoTyrant::RDBIT_DECIMAL
decimal string
TokyoTyrant::RDBIT_TOKEN
token inverted index (Tokyo Tyrant >= 1.1.29)
TokyoTyrant::RDBIT_QGRAM
QGRAM inverted index (Tokyo Tyrant >= 1.1.29)
TokyoTyrant::RDBIT_OPT
optimize
TokyoTyrant::RDBIT_VOID
void
TokyoTyrant::RDBIT_KEEP
keep existing index
TokyoTyrant::RDBQCFTS_PH
full-text search with the phrase of (Tokyo Tyrant >= 1.1.29)
TokyoTyrant::RDBQCFTS_AND
full-text search with all tokens in (Tokyo Tyrant >= 1.1.29)
TokyoTyrant::RDBQCFTS_OR
full-text search with at least one token in (Tokyo Tyrant >= 1.1.29)
TokyoTyrant::RDBQCFTS_EX
full-text search with the compound expression of (Tokyo Tyrant >=
1.1.29)
TokyoTyrant::RDBQCFTS_AND
Metasearch union between records (Tokyo Tyrant >= 1.1.33)
TokyoTyrant::RDBQCFTS_OR
Metasearch intersection between records (Tokyo Tyrant >= 1.1.33)
TokyoTyrant::RDBQCFTS_EX
Metasearch difference between records (Tokyo Tyrant >= 1.1.33)
TokyoTyrant::RDBT_RECON
Whether to reconnect on connection failure. It is recommended to have
this parameter on for persistent connections
TokyoTyrant::RDBXOLCK_REC
record locking
TokyoTyrant::RDBXOLCK_GLB
global locking
TokyoTyrant::RDBREC_INT
record type int
TokyoTyrant::RDBREC_DBL
record type float (double)
TokyoTyrant::TTE_SUCCESS
success
TokyoTyrant::TTE_INVALID
invalid operation
TokyoTyrant::TTE_NOHOST
host not found
TokyoTyrant::TTE_REFUSED
connection refused
TokyoTyrant::TTE_SEND
send error
TokyoTyrant::TTE_RECV
recv error
TokyoTyrant::TTE_KEEP
record exist
TokyoTyrant::TTE_NOREC
no record found
TokyoTyrant::TTE_MISC
miscellaneous error
TokyoTyrant::add
Adds to a numeric key
说明
public <span
class="type">intfloat <span
class="methodname">TokyoTyrant::add ( <span
class="methodparam">string $key
,
<span
class="type">intfloat
$increment
[, <span
class="type">int $type
=
0 ] )
Adds to an 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.
参数
key
The string key
increment
The amount to increment
type
TokyoTyrant::RDBREC_INT
or TokyoTyrant::RDBREC_DBL
constant.
If this parameter is omitted the type is guessed from the increment
parameters type.
返回值
Returns the new value on success
范例
示例 #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::RDBREC_DBL);
?>
以上例程的输出类似于:
6.5
参见
- TokyoTyrant::put
- TokyoTyrant::putcat
- TokyoTyrant::putkeep
TokyoTyrant::connect
Connect to a database
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connect ( <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]] )
Connects to a remote database
参数
host
The hostname
port
The port. Default: 1978
options
Connection options: timeout (default: 5.0), reconnect (default:
true
) and persistent (default: true
)
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::connect example
<?php
$tt = new TokyoTyrant();
$tt->connect("localhost", TokyoTyrant::RDBDEF_PORT)->put("test", "value");
?>
参见
- TokyoTyrant::connectUri
TokyoTyrant::connectUri
Connects to a database
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connectUri ( <span
class="methodparam">string $uri
)
Connects to a database using an uri
参数
uri
An URI to the database. For example tcp://localhost:1979/
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::connectUri example
<?php
$tt = new TokyoTyrant();
$tt->connectUri("tcp://localhost:1978/")->put("test", "hi");
?>
参见
- TokyoTyrant::connect
TokyoTyrant::__construct
Construct a new TokyoTyrant object
说明
public <span
class="methodname">TokyoTyrant::__construct ([ <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]]] )
Constructs a new TokyoTyrant object and optionally connects to the database
参数
host
The hostname. Default: null
port
port number. Default: 1978
options
Connection options: timeout (default: 5.0), reconnect (default:
true
) and persistent (default: true
)
返回值
Throws TokyoTyrantException if connection to database fails
参见
- TokyoTyrant::connect
- TokyoTyrant::connectUri
TokyoTyrant::copy
Copies the database
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::copy ( <span
class="methodparam">string $path
)
Makes a copy of the current database
参数
path
Path to where to copy the database. The user running the remote database
must have a write access to the directory.
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::copy example
<?php
$tt = new TokyoTyrant("localhost", 1978);
$tt->copy("/tmp/foobar.tct");
?>
参见
- TokyoTyrant::restore
TokyoTyrant::ext
Execute a remote script
说明
public string
TokyoTyrant::ext ( <span
class="methodparam">string $name
,
int
$options
, <span
class="type">string $key
, <span
class="methodparam">string $value
)
Executes a remote script extension.
参数
name
Name of the function to execute
options
Either TokyoTyrant::RDBXO_LCKREC
for record locking and
TokyoTyrant::RDBXO_LCKGLB
for global locking.
key
The key to pass to the function
value
The value to pass to the function
返回值
Returns the result of the script function
范例
示例 #1 TokyoTyrant::ext example
<?php
$tt = new TokyoTyrant("localhost", 1978);
echo $tt->ext("somefunc", TokyoTyrant::RDBXO_LCKREC, "some_key", "some_value");
?>
TokyoTyrant::fwmKeys
Returns the forward matching keys
说明
public array
TokyoTyrant::fwmKeys ( <span
class="methodparam">string $prefix
,
int
$max_recs
)
Returns the forward matching keys from the database
参数
prefix
Prefix of the keys
max_recs
Maximum records to return
返回值
Returns an array of matching keys. The values are not returned
范例
示例 #1 TokyoTyrant::fwmKeys example
<?php
$tt = new TokyoTyrant("localhost");
/* Create 20 macthing keys */
for ($i = 0; $i < 20; $i++) {
$tt->put("key_" . $i, "value_" . $i);
}
/* Create 20 non-macthing keys */
for ($i = 0; $i < 20; $i++) {
$tt->put("something_" . $i, "data_" . $i);
}
/* Get five matching keys */
var_dump($tt->fwmKeys("key_", 5));
?>
以上例程的输出类似于:
array(5) {
[0]=>
string(5) "key_5"
[1]=>
string(6) "key_14"
[2]=>
string(5) "key_6"
[3]=>
string(6) "key_15"
[4]=>
string(5) "key_7"
}
TokyoTyrant::get
The get purpose
说明
public mixed
TokyoTyrant::get ( <span
class="methodparam">mixed $keys
)
This method is used to return a value or multiple values. This method accepts a string or an <span class="type">array as a value.
参数
keys
A string key or an <span
class="type">array of string keys
返回值
Returns a string or an array based on the given parameters. Throws a TokyoTyrantException on error. If string is passed null is returned if the key is not found. In case an array is given as an parameter only existing keys will be returned. It is not an error to pass a key that does not exist.
范例
示例 #1 TokyoTyrant::get example
<?php
$tt = new TokyoTyrant("localhost", 1978);
$tt->put("key1", "value1");
$tt->put("key2", "value2");
var_dump($tt->get(array("key1", "key2")));
var_dump($tt->get("key1"));
?>
以上例程会输出:
array(2) {
["key1"]=>
string(6) "value1"
["key2"]=>
string(6) "value2"
}
string(6) "value1"
参见
- TokyoTyrant::put
TokyoTyrant::getIterator
Get an iterator
说明
public <span class="type">TokyoTyrantIterator <span class="methodname">TokyoTyrant::getIterator ( <span class="methodparam">void )
Gets an iterator for iterating all keys / values in the database.
参数
此函数没有参数。
返回值
This method returns TokyoTyrantIterator object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::getIterator example
<?php
$tt = new TokyoTyrant("localhost");
$it = $tt->getIterator();
foreach ($it as $k => $v) {
}
?>
参见
- TokyoTyrantTable::getQuery
- TokyoTyrantTable::getIterator
TokyoTyrant::num
Number of records in the database
说明
public int <span class="methodname">TokyoTyrant::num ( <span class="methodparam">void )
Returns the number of records in the database
参数
此函数没有参数。
返回值
Returns number of records in the database
范例
示例 #1 TokyoTyrant::num example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Echo the number of records */
echo $tt->num();
?>
以上例程的输出类似于:
1234
参见
- TokyoTyrant::stat
TokyoTyrant::out
Removes records
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::out ( <span
class="methodparam">mixed $keys
)
Removes a record or multiple records. This method accepts a <span class="type">string for a single key or an array of keys for multiple records.
参数
keys
A string key or an <span
class="type">array of string keys
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::out example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
$tt->put("test1", "value1");
$tt->put("test2", "value2");
$tt->out(array("test1", "test2"));
?>
参见
- TokyoTyrant::put
TokyoTyrant::put
Puts values
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::put ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
Puts a key-value pair into the database or multiple key-value pairs. If
keys
is string then the second parameter value defines the value. The
second parameter is mandatory if keys
is a string. If the key exists
the value will be replaced with new value.
参数
keys
A string key or an array of key-value pairs
value
The value in case a string key is used
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::put example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Put single key-value pair */
$tt->put("key", "value");
/* Put key-value pairs, new value overwrites the old */
$tt->put(array("key1" => "value1", "key" => "value2"));
/* Get back one key */
echo $tt->get("key");
?>
以上例程会输出:
value2
参见
- TokyoTyrant::putKeep
- TokyoTyrant::putCat
TokyoTyrant::putCat
Concatenates to a record
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putCat ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
Appends a value into existing key or multiple values if keys
is an
array. The second parameter is mandatory if keys
is a string. If the
record does not exist a new record is created.
参数
keys
A string key or an <span
class="type">array of key-value pairs
value
The value in case a string key is used
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::putCat example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Create a new key */
$tt->put("key", "value");
/* Concatenate single key-value pair */
$tt->putCat("key", " has more data");
/* Echo the key */
echo $tt->get("key");
?>
以上例程会输出:
value has more data
参见
- TokyoTyrant::put
- TokyoTyrant::putKeep
TokyoTyrant::putKeep
Puts a record
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putKeep ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
Puts a key-value pair into the database or multiple key-value pairs. If
keys
is string then the second parameter value defines the value. The
second parameter is mandatory if keys
is a string. If the key already
exists this method throws an exception indicating that the records
exists.
参数
keys
A string key or an <span
class="type">array of key-value pairs
value
The string value
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
范例
示例 #1 tokyotyrant::putKeep example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Create a new key */
$tt->put("key", "value");
try {
$tt->putKeep("key", "new value");
} catch (TokyoTyrantException $e) {
if ($e->getCode() === TokyoTyrant::TTE_KEEP) {
echo "Existing record! Not modified\n";
} else {
echo "Error: " , $e->getMessage() , "\n";
}
}
echo $tt->get("key");
?>
以上例程会输出:
Existing record! Not modified
value
参见
- TokyoTyrant::put
- TokyoTyrant::putCat
TokyoTyrant::putNr
Puts value
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putNr ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
Puts a key-value pair into the database or multiple key-value pairs. If
keys
is string then the second parameter value defines the value. The
second parameter is mandatory if keys
is a string. This method does
not wait for the response from the server.
参数
keys
A string key or an array of key-value pairs
value
The value in case a string key is used
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::putNr example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Put single key-value pair */
$tt->putNr("key", "value");
/* Put key-value pairs */
$tt->putNr(array("key1" => "value1", "key2" => "value2"));
/* Get back one key */
echo $tt->get("key1");
?>
以上例程会输出:
value1
参见
- TokyoTyrant::putNr
- TokyoTyrant::putKeep
- TokyoTyrant::putCat
TokyoTyrant::putShl
Concatenates to a record
说明
public mixed
TokyoTyrant::putShl ( <span
class="methodparam">string $key
,
string
$value
, <span
class="type">int $width
)
Concatenate to a record and shift to left.
参数
key
A string key
value
The value to concatenate
width
The width of the record
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::putShl example
<?php
/* Connect to a database on default port */
$tt = new TokyoTyrant("localhost");
/* Create a new key */
$tt->put("key", "just a long piece of data");
/* Concatenate and shift to left */
$tt->putShl("key", " and string", 15);
/* Echo the key */
echo $tt->get("key");
?>
以上例程会输出:
data and string
参见
- TokyoTyrant::put
- TokyoTyrant::putKeep
- TokyoTyrant::putCat
TokyoTyrant::restore
Restore the database
说明
public mixed
TokyoTyrant::restore ( <span
class="methodparam">string $log_dir
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
Restore the database from the update log.
Warning
This method is not supported on 32bit platforms.
参数
log_dir
Directory where the log is
timestamp
Beginning timestamp with microseconds
check_consistency
Whether to check consistency: Default: true
返回值
This method returns the current object and throws TokyoTyrantException on failure.
TokyoTyrant::setMaster
Set the replication master
说明
public mixed
TokyoTyrant::setMaster ( <span
class="methodparam">string $host
,
int $port
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
Sets the replication master of the database
Warning
This method is not supported on 32bit platforms.
参数
host
Hostname of the replication master. If null
the replication is
disabled.
port
Port of the replication master
timestamp
Beginning timestamp with microseconds
check_consistency
Whether to check consistency.
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::setMaster example
<?php
/* Connect to a database */
$tt = new TokyoTyrant("tokyotyrant.example.com");
/* Disable the replication */
$tt->setMaster(NULL, 0, 0);
?>
参见
- Classname::Method
TokyoTyrant::size
Returns the size of the value
说明
public int <span
class="methodname">TokyoTyrant::size ( <span
class="methodparam">string $key
)
Returns the size of a value by key
参数
key
The key of which size to fetch
返回值
Returns the size of the key or throw TokyoTyrantException on error
范例
示例 #1 TokyoTyrant::size example
<?php
$tt = new TokyoTyrant("localhost");
$tt->put("test_key", "12345");
echo $tt->size("test_key");
?>
以上例程会输出:
5
TokyoTyrant::stat
Get statistics
说明
public array TokyoTyrant::stat ( <span class="methodparam">void )
Returns statistics of the remote database
参数
此函数没有参数。
返回值
Returns an array of key value pairs describing the statistics
范例
示例 #1 TokyoTyrant::stat example
<?php
$tt = new TokyoTyrant("localhost");
var_dump($tt->stat());
?>
以上例程的输出类似于:
array(19) {
["version"]=>
string(6) "1.1.28"
["libver"]=>
string(3) "311"
["protver"]=>
string(4) "0.91"
["os"]=>
string(5) "Linux"
["time"]=>
string(17) "1247358357.665630"
["pid"]=>
string(5) "14348"
["sid"]=>
string(8) "59025947"
["type"]=>
string(9) "on-memory"
["path"]=>
string(1) "*"
["rnum"]=>
string(1) "4"
["size"]=>
string(6) "262856"
["bigend"]=>
string(1) "0"
["fd"]=>
string(1) "5"
["loadavg"]=>
string(8) "0.000000"
["memsize"]=>
string(8) "77328384"
["memrss"]=>
string(7) "1183744"
["ru_real"]=>
string(13) "162776.042152"
["ru_user"]=>
string(8) "0.476029"
["ru_sys"]=>
string(8) "8.652540"
}
参见
- Classname::Method
TokyoTyrant::sync
Synchronize the database
说明
public mixed TokyoTyrant::sync ( <span class="methodparam">void )
Synchronizes the database on to the physical device
参数
此函数没有参数。
返回值
This method returns the current object and throws TokyoTyrantException on failure.
TokyoTyrant::tune
Tunes connection values
说明
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::tune ( <span
class="methodparam">float $timeout
[, int
$options
=
TokyoTyrant::RDBT_RECON ] )
Tunes database connection options.
参数
timeout
The objects timeout value (default: 5.0)
options
Bitmask of options to tune. This can be either 0 or
TokyoTyrant::RDBT_RECON
. It is recommended not to change the
second parameter.
返回值
This method returns a reference to the current object and throws TokyoTyrantException on failure.
TokyoTyrant::vanish
Empties the database
说明
public mixed TokyoTyrant::vanish ( <span class="methodparam">void )
Empties a remote database
参数
此函数没有参数。
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrant::vanish example
<?php
$tt = new TokyoTyrant("localhost");
$tt->vanish();
?>
参见
- TokyoTyrant::out
简介
Provides an API to the table databases. A table database can be create using the following command: ttserver -port 1979 /tmp/tt_table.tct. In Tokyo Tyrant the table API is a schemaless database which can store arbitrary amount of key-value pairs under a single primary key.
类摘要
TokyoTyrantTable
class TokyoTyrantTable <span class="ooclass"> extends TokyoTyrant {
/* 方法 */
public void
add ( <span
class="type">string $key
, <span
class="methodparam">mixed $increment
[, string
$type
] )
public int <span class="methodname">genUid ( void )
public array
get ( <span
class="type">mixed $keys
)
public <span class="type">TokyoTyrantIterator <span class="methodname">getIterator ( <span class="methodparam">void )
public <span class="type">TokyoTyrantQuery <span class="methodname">getQuery ( <span class="methodparam">void )
public void
out ( <span
class="type">mixed $keys
)
public int <span
class="methodname">put ( <span
class="type">string $key
, <span
class="methodparam">array $columns
)
public void
putCat ( <span
class="type">string $key
, <span
class="methodparam">array $columns
)
public void
putKeep ( <span
class="methodparam">string $key
,
array
$columns
)
public void
putNr ( <span
class="type">mixed $keys
[, <span
class="methodparam">string $value
]
)
public void
putShl ( <span
class="type">string $key
, <span
class="methodparam">string $value
,
int $width
)
public mixed
setIndex ( <span
class="methodparam">string $column
,
int $type
)
/* 继承的方法 */
public <span
class="type">intfloat <span
class="methodname">TokyoTyrant::add ( <span
class="methodparam">string $key
,
<span
class="type">intfloat
$increment
[, <span
class="type">int $type
=
0 ] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connect ( <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connectUri ( <span
class="methodparam">string $uri
)
public <span
class="methodname">TokyoTyrant::__construct ([ <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]]] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::copy ( <span
class="methodparam">string $path
)
public string
TokyoTyrant::ext ( <span
class="methodparam">string $name
,
int
$options
, <span
class="type">string $key
, <span
class="methodparam">string $value
)
public array
TokyoTyrant::fwmKeys ( <span
class="methodparam">string $prefix
,
int
$max_recs
)
public mixed
TokyoTyrant::get ( <span
class="methodparam">mixed $keys
)
public <span class="type">TokyoTyrantIterator <span class="methodname">TokyoTyrant::getIterator ( <span class="methodparam">void )
public int <span class="methodname">TokyoTyrant::num ( <span class="methodparam">void )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::out ( <span
class="methodparam">mixed $keys
)
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::put ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putCat ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putKeep ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putNr ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
public mixed
TokyoTyrant::putShl ( <span
class="methodparam">string $key
,
string
$value
, <span
class="type">int $width
)
public mixed
TokyoTyrant::restore ( <span
class="methodparam">string $log_dir
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public mixed
TokyoTyrant::setMaster ( <span
class="methodparam">string $host
,
int $port
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public int <span
class="methodname">TokyoTyrant::size ( <span
class="methodparam">string $key
)
public array TokyoTyrant::stat ( <span class="methodparam">void )
public mixed TokyoTyrant::sync ( <span class="methodparam">void )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::tune ( <span
class="methodparam">float $timeout
[, int
$options
=
TokyoTyrant::RDBT_RECON ] )
public mixed TokyoTyrant::vanish ( <span class="methodparam">void )
}
TokyoTyrantTable::add
Adds a record
说明
public void
TokyoTyrantTable::add ( <span
class="methodparam">string $key
,
mixed
$increment
[, <span
class="type">string $type
] )
This method is not supported with table databases.
参数
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.
返回值
This method throws an TokyoTyrantException if used through this class.
参见
- TokyoTyrant::add
TokyoTyrantTable::genUid
Generate unique id
说明
public int <span class="methodname">TokyoTyrantTable::genUid ( <span class="methodparam">void )
Generates an unique id inside the table database. In table databases rows are referenced using a numeric primary key.
参数
此函数没有参数。
返回值
Returns an unique id or throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantTable::genUid example
<?php
$tt = new TokyoTyrantTable("localhost", 1122);
echo $tt->genUid();
?>
以上例程的输出类似于:
4
参见
- TokyoTyrantTable::put
TokyoTyrantTable::get
Get a row
说明
public array
TokyoTyrantTable::get ( <span
class="methodparam">mixed $keys
)
Gets a row from table database. keys
is a single integer for the
primary key of the row or an array of integers for multiple rows.
参数
keys
The primary key, can be a string or an integer
返回值
Returns the row as an array
范例
示例 #1 TokyoTyrantTable::get example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Get the row back */
var_dump($tt->get($index));
?>
以上例程会输出:
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
注释
Note:
Starting from version 0.3.0 this method accepts array as parameter. Please note that multi-get on tables is not binary-safe.
参见
- TokyoTyrantTable::put
TokyoTyrantTable::getIterator
Get an iterator
说明
public <span class="type">TokyoTyrantIterator <span class="methodname">TokyoTyrantTable::getIterator ( <span class="methodparam">void )
Gets an iterator for iterating all keys / values in the database.
参数
此函数没有参数。
返回值
This method returns TokyoTyrantIterator object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrantTable::getIterator example
<?php
$tt = new TokyoTyrantTable("localhost");
$it = $tt->getIterator();
foreach ($it as $k => $v) {
var_dump($k, $v);
}
?>
参见
- TokyoTyrantTable::getQuery
- TokyoTyrant::getIterator
TokyoTyrantTable::getQuery
Get a query object
说明
public <span class="type">TokyoTyrantQuery <span class="methodname">TokyoTyrantTable::getQuery ( <span class="methodparam">void )
Get a query object to execute searches on the database
参数
此函数没有参数。
返回值
Returns TokyoTyrantQuery on success and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantTable::getQuery example
<?php
/* Connect to a table database */
$table = new TokyoTyrantTable("localhost", 1979);
/* Put a few rows */
$table->put(null, array("column1" => "some data", "column2" => "more data"));
$table->put(null, array("something" => "value", "data" => "good data"));
/* Get query object */
$query = $table->getQuery();
/* Add condition to query */
$query->addCond('data', TokyoTyrant::RDBQC_STREQ, 'good data');
/* Get matching rows */
var_dump($query->search());
?>
以上例程的输出类似于:
array(1) {
[11]=>
array(2) {
["something"]=>
string(5) "value"
["data"]=>
string(9) "good data"
}
}
参见
- TokyoTyrantQuery::search
- TokyoTyrantQuery::out
TokyoTyrantTable::out
Remove records
说明
public void
TokyoTyrantTable::out ( <span
class="methodparam">mixed $keys
)
Removes records from a table database.
参数
keys
A single integer key or an array of integers
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrantTable::out example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Delete the row */
$tt->out($index);
?>
参见
- TokyoTyrantTable::put
TokyoTyrantTable::put
Store a row
说明
public int <span
class="methodname">TokyoTyrantTable::put ( <span
class="methodparam">string $key
,
array
$columns
)
Puts a new row into the database. This method parameters are key
which
is the primary key of the row, passing null
will generate a new
unique id. value
is an array containing the row contents which is
usually key value pairs.
参数
key
The primary key of the row
columns
The row contents
返回值
Returns the primary key on success and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantTable::put example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Get the row back */
var_dump($tt->get($index));
/* Modify an existing row */
$tt->put($index, array("column1" => "other data", "column2" => "better data"));
/* Get the row back */
var_dump($tt->get($index));
?>
以上例程会输出:
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
array(2) {
["column1"]=>
string(10) "other data"
["column2"]=>
string(11) "better data"
}
参见
- TokyoTyrantTable::get
TokyoTyrantTable::putCat
Concatenates to a row
说明
public void
TokyoTyrantTable::putCat ( <span
class="methodparam">string $key
,
array
$columns
)
This method can be used to add new columns to existing records. Existing keys will be left unmodified but any new columns will be appended to the row. Passing null as key will generate a new row.
参数
key
The primary key of the row or null
columns
Array of row contents
返回值
Returns the primary key and throws TokyoTyrantException on error.
范例
示例 #1 TokyoTyrantTable::putCat example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Get the row back */
var_dump($tt->get($index));
/* Modify an existing row */
$tt->putcat($index, array("column1" => "something new", "new_column" => "other data"));
/* Get the row back */
var_dump($tt->get($index));
?>
以上例程会输出:
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
array(3) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
["new_column"]=>
string(10) "other data"
}
参见
- TokyoTyrantTable::put
TokyoTyrantTable::putKeep
Put a new record
说明
public void
TokyoTyrantTable::putKeep ( <span
class="methodparam">string $key
,
array
$columns
)
Puts a new record into the database. If the key already exists this method throws an exception indicating that the records exists.
参数
key
The primary key of the row or null
columns
Array of the row contents
返回值
Returns the primary key and throws TokyoTyrantException on error.
范例
示例 #1 TokyoTyrantTable::putKeep example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Get the row back */
var_dump($tt->get($index));
try {
$tt->putKeep($index, array("column1" => "something new", "new_column" => "other data"));
} catch (TokyoTyrantException $e) {
if ($e->getCode() === TokyoTyrant::TTE_KEEP) {
echo "Existing record! Not modified\n";
} else {
echo "Error: " , $e->getMessage() , "\n";
}
}
/* Get the row back */
var_dump($tt->get($index));
?>
以上例程的输出类似于:
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
Existing record! Not modified
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
参见
- TokyoTyrantTable::put
TokyoTyrantTable::putNr
Puts value
说明
public void
TokyoTyrantTable::putNr ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
This method is not supported on table databases. Calling this method through TokyoTyrantTable is considered an error and an TokyoTyrantException will be thrown.
参数
keys
A string key or an array of key-value pairs
value
The value in case a string key is used
返回值
This method is not supported on table databases. Calling this method through TokyoTyrantTable is considered an error and an TokyoTyrantException will be thrown.
参见
- TokyoTyrant::putNr
- TokyoTyrant::putKeep
- TokyoTyrant::putCat
TokyoTyrantTable::putShl
Concatenates to a record
说明
public void
TokyoTyrantTable::putShl ( <span
class="methodparam">string $key
,
string
$value
, <span
class="type">int $width
)
This method is not supported on table databases. Calling this method through TokyoTyrantTable is considered an error and an TokyoTyrantException will be thrown.
参数
key
A string key
value
The value to concatenate
width
The width of the record
返回值
This method is not supported on table databases.
参见
- TokyoTyrant::put
- TokyoTyrant::putKeep
- TokyoTyrant::putCat
- TokyoTyrantTable::put
- TokyoTyrantTable::putKeep
- TokyoTyrantTable::putCat
TokyoTyrantTable::setIndex
Sets index
说明
public mixed
TokyoTyrantTable::setIndex ( <span
class="methodparam">string $column
,
int $type
)
Sets an index on a specified column. The index type is one of the
*`TokyoTyrant::RDBIT_** constants. Passing **
TokyoTyrant::RDBIT_VOID`** removes the index.
参数
column
The name of the column
type
The index type
返回值
This method returns the current object and throws TokyoTyrantException on failure.
简介
This class is used to query the table databases
类摘要
TokyoTyrantQuery
class TokyoTyrantQuery <span class="oointerface">implements <span class="interfacename">Iterator {
/* 方法 */
public mixed
addCond ( <span
class="methodparam">string $name
,
int $op
,
string
$expr
)
public <span
class="methodname">__construct ( <span
class="methodparam">TokyoTyrantTable
$table
)
public int <span class="methodname">count ( void )
public array current ( <span class="methodparam">void )
public string hint ( <span class="methodparam">void )
public string key ( <span class="methodparam">void )
public array
metaSearch ( <span
class="methodparam">array $queries
,
int $type
)
public array next ( <span class="methodparam">void )
public <span class="type">TokyoTyrantQuery out ( void )
public bool rewind ( <span class="methodparam">void )
public array search ( <span class="methodparam">void )
public mixed
setLimit ([ <span
class="methodparam">int $max
[,
int $skip
]] )
public mixed
setOrder ( <span
class="methodparam">string $name
,
int $type
)
public bool valid ( <span class="methodparam">void )
}
TokyoTyrantQuery::addCond
Adds a condition to the query
说明
public mixed
TokyoTyrantQuery::addCond ( <span
class="methodparam">string $name
,
int $op
,
string
$expr
)
Adds a condition to the query. Condition can be something like: get all keys which value matches expr.
参数
name
Name of the column in the condition
op
The operator. One of the *`TokyoTyrant::RDBQC_`** constants
expr
The expression
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrantQuery::addCond example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "not here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Dump the search results */
var_dump($query->search());
?>
以上例程会输出:
array(2) {
[1]=>
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(14) "something here"
}
[4]=>
array(2) {
["column45"]=>
string(11) "random data"
["column2"]=>
string(25) "something along the lines"
}
}
参见
- Classname::Method
TokyoTyrantQuery::__construct
Construct a new query
说明
public <span
class="methodname">TokyoTyrantQuery::__construct ( <span
class="methodparam">TokyoTyrantTable
$table
)
Construct a new query object
参数
table
TokyoTyrantTable object with active database connection
返回值
Returns a new TokyoTyrantQuery object and throws TokyoTyrantException on error
范例
示例 #1 <span class="methodname">TokyoTyrantQuery::__construct example
<?php
$tt = new TokyoTyrantTable("localhost", 1979);
$query = new TokyoTyrantQuery($tt);
/* Work with $query */
?>
参见
- TokyoTyrantTable::getQuery
TokyoTyrantQuery::count
Counts records
说明
public int <span class="methodname">TokyoTyrantQuery::count ( <span class="methodparam">void )
Returns a count of how many records a query returns.
参数
此函数没有参数。
返回值
Returns a count of matching rows and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantQuery::count example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "not here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Count the results */
var_dump($query->count());
?>
以上例程会输出:
int(2)
参见
- TokyoTyrantQuery::out
- TokyoTyrantQuery::search
- TokyoTyrantQuery::metaSearch
TokyoTyrantQuery::current
Returns the current element
说明
public array TokyoTyrantQuery::current ( <span class="methodparam">void )
Returns the current element. Part of Iterator interface
参数
此函数没有参数。
返回值
Returns the current row
范例
示例 #1 TokyoTyrantQuery iterator example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Iterate the results */
foreach ($query as $key => $value) {
echo "pk: $key, columns: ", count($value) ,"\n";
}
?>
以上例程的输出类似于:
pk: 1, columns: 2
pk: 4, columns: 2
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::hint
Get the hint string of the query
说明
public string TokyoTyrantQuery::hint ( <span class="methodparam">void )
Get the hint string of the query. The hint string contains information about an executed query and it could be compared to for example MySQL EXPLAIN statement.
参数
此函数没有参数。
返回值
This method always returns a string
范例
示例 #1 TokyoTyrantQuery::hint example
<?php
$tt = new TokyoTyrantTable("localhost", 1979);
$tt->vanish();
for ($i = 0; $i < 11; $i++) {
$tt->put(null, array('a_col' => 'a' . $i, 'b_col' => 'b' . $i));
}
$query = $tt->getQuery();
$query->addCond('a_col', TokyoTyrant::RDBQC_STRBW, 'a');
$query->search();
var_dump($query->hint());
?>
以上例程的输出类似于:
string(72) "
scanning the whole table
result set size: 11
leaving the natural order
"
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::key
Returns the current key
说明
public string TokyoTyrantQuery::key ( <span class="methodparam">void )
Returns the current key. Part of the Iterator interface
参数
此函数没有参数。
返回值
Returns the current key and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantQuery iterator example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Iterate the results */
foreach ($query as $key => $value) {
echo "pk: $key, columns: ", count($value) ,"\n";
}
?>
以上例程的输出类似于:
pk: 1, columns: 2
pk: 4, columns: 2
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::metaSearch
Retrieve records with multiple queries
说明
public array
TokyoTyrantQuery::metaSearch ( <span
class="methodparam">array $queries
,
int $type
)
Executes multiple queries on a database and returns matching records. The current object is always the left most object in the search.
参数
queries
Array of TokyoTyrantQuery objects
type
One of the *`TokyoTyrant::RDBMS_`** constants
返回值
Returns the matching rows and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantQuery::metaSearch example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add test data */
$tt->put('cherry', array('color' => 'red'));
$tt->put('strawberry', array('color' => 'red'));
$tt->put('apple', array('color' => 'green'));
$tt->put('lemon', array('color' => 'yellow'));
/* First query */
$query = $tt->getQuery();
$query->addCond('color', TokyoTyrant::RDBQC_STREQ, 'red')->setOrder('color', TokyoTyrant::RDBQO_STRASC);
/* Second query */
$query1 = $tt->getQuery();
$query1->addCond('color', TokyoTyrant::RDBQC_STREQ, 'yellow');
/* Get union between the queries */
var_dump($query->metaSearch(array($query1), TokyoTyrant::RDBMS_UNION));
?>
以上例程会输出:
array(3) {
["cherry"]=>
array(1) {
["color"]=>
string(3) "red"
}
["strawberry"]=>
array(1) {
["color"]=>
string(3) "red"
}
["lemon"]=>
array(1) {
["color"]=>
string(6) "yellow"
}
}
参见
- TokyoTyrantQuery::search
TokyoTyrantQuery::next
Moves the iterator to next entry
说明
public array TokyoTyrantQuery::next ( <span class="methodparam">void )
Returns the next result in the resultset. Part of the Iterator interface.
参数
此函数没有参数。
返回值
Returns the next row and throws TokyoTyrantException on error.
范例
示例 #1 TokyoTyrantQuery iterator example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Iterate the results */
foreach ($query as $key => $value) {
echo "pk: $key, columns: ", count($value) ,"\n";
}
?>
以上例程的输出类似于:
pk: 1, columns: 2
pk: 4, columns: 2
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::out
Removes records based on query
说明
public <span class="type">TokyoTyrantQuery <span class="methodname">TokyoTyrantQuery::out ( <span class="methodparam">void )
Removes all records that match the query. Works exactly like search but removes the records instead of returning them.
参数
此函数没有参数。
返回值
This method returns the current object and throws TokyoTyrantException on failure.
范例
示例 #1 TokyoTyrantQuery::out example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Remove matching records */
$query->out();
?>
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::rewind
Rewinds the iterator
说明
public bool TokyoTyrantQuery::rewind ( <span class="methodparam">void )
Rewind the resultset and executes the query if it has not been executed. Part of the Iterator interface.
参数
此函数没有参数。
返回值
Returns true
范例
示例 #1 TokyoTyrantQuery iterator example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Iterate the results */
foreach ($query as $key => $value) {
echo "pk: $key, columns: ", count($value) ,"\n";
}
?>
以上例程的输出类似于:
pk: 1, columns: 2
pk: 4, columns: 2
参见
- TokyoTyrantQuery::addCond
TokyoTyrantQuery::search
Searches records
说明
public array TokyoTyrantQuery::search ( <span class="methodparam">void )
Executes a search on the table database. Returns an array of arrays containing the matching records. In the returned array the first level is the primary key of the data and the second level is the row data.
参数
此函数没有参数。
返回值
Returns the matching rows and throws TokyoTyrantException on error
范例
示例 #1 TokyoTyrantQuery::search example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "not here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Dump the search results */
var_dump($query->search());
?>
以上例程会输出:
array(2) {
[1]=>
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(14) "something here"
}
[4]=>
array(2) {
["column45"]=>
string(11) "random data"
["column2"]=>
string(25) "something along the lines"
}
}
参见
- TokyoTyrantQuery::out
- TokyoTyrantQuery::metaSearch
TokyoTyrantQuery::setLimit
Limit results
说明
public mixed
TokyoTyrantQuery::setLimit ([ <span
class="methodparam">int $max
[,
int $skip
]] )
Set the maximum amount of records to return on a query.
参数
max
Maximum amount of records. Default: -1
skip
How many records to skip from the start. Default: -1
返回值
This method returns the current object and throws TokyoTyrantException on failure.
TokyoTyrantQuery::setOrder
Orders results
说明
public mixed
TokyoTyrantQuery::setOrder ( <span
class="methodparam">string $name
,
int $type
)
Sets the order of a query
参数
name
The column name to apply the ordering on.
type
The type
can be one of the following constants:
-
TokyoTyrant::RDBQO_STRASC
- String ascending -
TokyoTyrant::RDBQO_STRDESC
- String descending -
TokyoTyrant::RDBQO_NUMASC
- Numberic ascending -
TokyoTyrant::RDBQO_NUMDESC
- String descending
返回值
This method returns the current object.
TokyoTyrantQuery::valid
Checks the validity of current item
说明
public bool TokyoTyrantQuery::valid ( <span class="methodparam">void )
Checks if the current item is valid. Part of the Iterator interface
参数
此函数没有参数。
返回值
Returns true
if the current item is valid and false
if not.
范例
示例 #1 TokyoTyrantQuery iterator example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "foobar here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Iterate the results */
foreach ($query as $key => $value) {
echo "pk: $key, columns: ", count($value) ,"\n";
}
?>
以上例程的输出类似于:
pk: 1, columns: 2
pk: 4, columns: 2
参见
- TokyoTyrantQuery::addCond
简介
Provides an iterator for TokyoTyrant and TokyoTyrantTable objects. The iterator iterates over all keys and values in the database. TokyoTyrantIterator was added in version 0.2.0.
类摘要
TokyoTyrantIterator
class TokyoTyrantIterator <span class="oointerface">implements <span class="interfacename">Iterator {
/* Methods */
public <span
class="methodname">__construct ( <span
class="methodparam">mixed $object
)
public mixed current ( <span class="methodparam">void )
public mixed key ( <span class="methodparam">void )
public mixed next ( <span class="methodparam">void )
public void rewind ( <span class="methodparam">void )
public bool valid ( <span class="methodparam">void )
/* Inherited methods */
public <span
class="type">intfloat <span
class="methodname">TokyoTyrant::add ( <span
class="methodparam">string $key
,
<span
class="type">intfloat
$increment
[, <span
class="type">int $type
=
0 ] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connect ( <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::connectUri ( <span
class="methodparam">string $uri
)
public <span
class="methodname">TokyoTyrant::__construct ([ <span
class="methodparam">string $host
[,
int $port
<span
class="initializer"> = TokyoTyrant::RDBDEF_PORT [, <span
class="methodparam">array $options
]]] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::copy ( <span
class="methodparam">string $path
)
public string
TokyoTyrant::ext ( <span
class="methodparam">string $name
,
int
$options
, <span
class="type">string $key
, <span
class="methodparam">string $value
)
public array
TokyoTyrant::fwmKeys ( <span
class="methodparam">string $prefix
,
int
$max_recs
)
public mixed
TokyoTyrant::get ( <span
class="methodparam">mixed $keys
)
public <span class="type">TokyoTyrantIterator <span class="methodname">TokyoTyrant::getIterator ( <span class="methodparam">void )
public int <span class="methodname">TokyoTyrant::num ( <span class="methodparam">void )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::out ( <span
class="methodparam">mixed $keys
)
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::put ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putCat ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putKeep ( <span
class="methodparam">mixed $keys
[,
string
$value
] )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::putNr ( <span
class="methodparam">mixed $keys
[,
string $value
<span
class="initializer"> = NULL ] )
public mixed
TokyoTyrant::putShl ( <span
class="methodparam">string $key
,
string
$value
, <span
class="type">int $width
)
public mixed
TokyoTyrant::restore ( <span
class="methodparam">string $log_dir
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public mixed
TokyoTyrant::setMaster ( <span
class="methodparam">string $host
,
int $port
,
int
$timestamp
[, <span
class="type">bool $check_consistency
= true
] )
public int <span
class="methodname">TokyoTyrant::size ( <span
class="methodparam">string $key
)
public array TokyoTyrant::stat ( <span class="methodparam">void )
public mixed TokyoTyrant::sync ( <span class="methodparam">void )
public <span
class="type">TokyoTyrant <span
class="methodname">TokyoTyrant::tune ( <span
class="methodparam">float $timeout
[, int
$options
=
TokyoTyrant::RDBT_RECON ] )
public mixed TokyoTyrant::vanish ( <span class="methodparam">void )
}
TokyoTyrantIterator::__construct
Construct an iterator
说明
public <span
class="methodname">TokyoTyrantIterator::__construct ( <span
class="methodparam">mixed $object
)
Construct a new TokyoTyrantIterator object. One connection can have
multiple iterators but it is not quaranteed that all items are traversed
in that case. object
parameter can be either an of instance
TokyoTyrant or TokyoTyrantTable.
参数
此函数没有参数。
返回值
Throws an exception if iterator initialization fails.
范例
示例 #1 <span class="methodname">TokyoTyrantIterator::__construct example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Passing null to put generates a new uid */
$index = $tt->put(null, array("column1" => "some data", "column2" => "more data"));
/* Construct an iterator */
$it = new TokyoTyrantIterator($tt);
foreach ($it as $value) {
var_dump($value);
}
?>
以上例程会输出:
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(9) "more data"
}
参见
- TokyoTyrantIterator::key
- TokyoTyrantIterator::current
- TokyoTyrantIterator::next
- TokyoTyrantIterator::rewind
- TokyoTyrantIterator::key
TokyoTyrantIterator::current
Get the current value
说明
public mixed TokyoTyrantIterator::current ( <span class="methodparam">void )
Returns the current value during iteration.
参数
此函数没有参数。
返回值
Returns the current value on success and false on failure.
参见
- TokyoTyrantIterator::valid
- TokyoTyrantIterator::key
- TokyoTyrantIterator::next
- TokyoTyrantIterator::rewind
TokyoTyrantIterator::key
Returns the current key
说明
public mixed TokyoTyrantIterator::key ( <span class="methodparam">void )
Returns the current key.
参数
此函数没有参数。
返回值
Returns the current key on success and false on failure.
参见
- TokyoTyrantIterator::valid
- TokyoTyrantIterator::current
- TokyoTyrantIterator::next
- TokyoTyrantIterator::rewind
TokyoTyrantIterator::next
Move to next key
说明
public mixed TokyoTyrantIterator::next ( <span class="methodparam">void )
Move to next key during iteration and return it's value.
参数
此函数没有参数。
返回值
Returns the next value on success and false on failure.
参见
- TokyoTyrantIterator::valid
- TokyoTyrantIterator::key
- TokyoTyrantIterator::current
- TokyoTyrantIterator::rewind
TokyoTyrantIterator::rewind
Rewinds the iterator
说明
public void TokyoTyrantIterator::rewind ( <span class="methodparam">void )
Rewinds the iterator for new iteration. Called automatically at the beginning of foreach.
参数
此函数没有参数。
返回值
Throws TokyoTyrantException if iterator initialization fails.
参见
- TokyoTyrantIterator::valid
- TokyoTyrantIterator::current
- TokyoTyrantIterator::next
- TokyoTyrantIterator::rewind
TokyoTyrantIterator::valid
Rewinds the iterator
说明
public bool TokyoTyrantIterator::valid ( <span class="methodparam">void )
Checks whether the internal pointer points to valid element.
参数
此函数没有参数。
返回值
Returns true
if the current item is valid and false
if not.
参见
- TokyoTyrantIterator::key
- TokyoTyrantIterator::current
- TokyoTyrantIterator::next
- TokyoTyrantIterator::rewind
简介
TokyoTyrantException
类摘要
tokyotyrantexception
class tokyotyrantexception <span class="ooclass"> extends Exception {
/* 属性 */
protected int
$code
;
/* 继承的属性 */
protected string
$message
;
protected int
$code
;
protected string
$file
;
protected int
$line
;
/* 继承的方法 */
final public string <span class="methodname">Exception::getMessage ( <span class="methodparam">void )
final public Throwable <span class="methodname">Exception::getPrevious ( <span class="methodparam">void )
final public mixed <span class="methodname">Exception::getCode ( <span class="methodparam">void )
final public string <span class="methodname">Exception::getFile ( <span class="methodparam">void )
final public int <span class="methodname">Exception::getLine ( <span class="methodparam">void )
final public array <span class="methodname">Exception::getTrace ( <span class="methodparam">void )
final public string <span class="methodname">Exception::getTraceAsString ( <span class="methodparam">void )
public string Exception::__toString ( <span class="methodparam">void )
final <span class="modifier">private void <span class="methodname">Exception::__clone ( <span class="methodparam">void )
}
属性
code
The exception code. This can be compared to *`TokyoTyrant::TTE_`**
constants