sqlite_fetch_single

SQLiteResult::fetchSingle

SQLiteUnbuffered::fetchSingle

(PHP 5 < 5.4.0, PECL sqlite >= 1.0.1)

sqlite_fetch_single -- SQLiteResult::fetchSingle -- SQLiteUnbuffered::fetchSingleFetches the first column of a result set as a string

说明

sqlite_fetch_single ( resource $result [, bool $decode_binary = TRUE ] ) : string

面向对象风格 (method):

SQLiteResult::fetchSingle ([ bool $decode_binary = TRUE ] ) : string
SQLiteUnbuffered::fetchSingle ([ bool $decode_binary = TRUE ] ) : string

sqlite_fetch_single() is identical to sqlite_fetch_array() except that it returns the value of the first column of the rowset.

This is the most optimal way to retrieve data when you are only interested in the values from a single column of data.

参数

result

The SQLite result resource. This parameter is not required when using the object-oriented method.

decode_binary

decode_binary 参数设置为 TRUE(默认值)时,PHP 会解码那些由 sqlite_escape_string() 编码后的二进制数据。通常应保留此值为其默认值,除非要与其他使用 SQLlite 的应用程序建立的数据交互。

返回值

Returns the first column value, as a string.

范例

Example #1 A sqlite_fetch_single() example

<?php
if ($dbhandle sqlite_open('mysqlitedb'0666$sqliteerror)) {

    
$sql "SELECT id FROM sometable WHERE id = 42";
    
$res sqlite_query($dbhandle$sql);

    if (
sqlite_num_rows($res) > 0) {
        echo 
sqlite_fetch_single($res); // 42
    
}
    
    
sqlite_close($dbhandle);
}
?>

参见

相关文章
php ibm db2 函数 returns an array indexed by column position representing a row in a result setphp ibm db2 函数 returns an array indexed by column name representing a row in a result setphp ibm db2 函数 returns an array indexed by both column name and position representing a row in a result setphp ibm db2 函数 returns the name of the column in the result setphp ibm db2 函数 returns the position of the named column in a result setphp ibm db2 函数 returns the precision of the indicated column in a result setphp ibm db2 函数 returns the scale of the indicated column in a result setphp ibm db2 函数 returns the data type of the indicated column in a result setphp ibm db2 函数 returns the width of the current value of the indicated column in a result setphp ibm db2 函数 returns a single column from a row in the result setphp dbx 函数 fetches rows from a query result that had the dbx result unbuffered flag setphp sqlite 函数 fetches a column from the current row of a result setphp sqlite 函数 fetches the current row from a result set as an arrayphp sqlite 函数 fetches all rows from a result set as an array of arraysphp sqlite 函数 fetches the next row from a result set as an arrayphp sqlite 函数 fetches the next row from a result set as an objectphp sqlite 函数 fetches the first column of a result set as a stringphp sqlite 函数 seek to the previous row number of a result setphp sqlite 函数 seek to a particular row number of a buffered result setphp sqlite 函数 executes a query and returns either an array for one single column or the value of the first row
关注编程学问公众号