PHP.mk документација

SQLite3Result::columnType

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

sqlite3result.columntype.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека sqlite3result.columntype.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
SQLite3Result::columnType

Референца за `sqlite3result.columntype.php` со подобрена типографија и навигација.

sqlite3result.columntype.php

SQLite3Result::columnType

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

SQLite3Result::columnTypeReturns the type of the nth column

= NULL

public SQLite3Result::columnType(int $column): int|false

Returns the type of the column identified by column.

Параметри

column

The numeric zero-based index of the column.

Вратени вредности

Returns the data type index of the column identified by column (one of SQLITE3_INTEGER, SQLITE3_FLOAT, SQLITE3_TEXT, SQLITE3_BLOB, или SQLITE3_NULL), или false if the column does not exist.

Белешки од корисници 3 белешки

phpnotes at carwash dot org
пред 14 години
This function never returns any value other than 5, indicating SQLITE3_NULL.  SQLite 3 doesn't have column types, it has column affinities.  Different rows of the same table (and rows resulting from a SELECT) can hold values of different types.  Therefore this API cannot return anything useful, and the method appears to be using SQLITE3_NULL as a placeholder. 

The function in useless and should be removed or marked as deprecated in future releases, so as not to give any programmer the false idea that the values returned are useful.
hairbysubaru at gmail dot com
пред 9 години
jean-marc is correct. SQLite determines column types dynamically based upon the returned record-set.
jean-marc at paratte dot ch
пред 11 години
To find the type of columns, you need to 'query' the SQL sentence, 'fetchArray' the 1rst row, and then extract the name and type of each column.

Example:

function _sqlite_fetch_all( $db, $sql ) {

    $sqlite = new SQLite3( $db);

    if( $sqlite->lastErrorCode() ) return;

    $result = $sqlite->query( $sql );

    $result->fetchArray( SQLITE3_NUM );
    $fieldnames = [];
    $fieldtypes = [];
    for( $colnum=0; $colnum<$result->numColumns(); $colnum++) {
        $fieldnames[] = $result->columnName($colnum);
        $fieldtypes[] = $result->columnType($colnum);
    }
    $result->reset();

    while( $row = $result->fetchArray( SQLITE3_NUM ) ) {

        for ($colnum=0; $colnum<count($row); $colnum++) {
            $col = &$row[$colnum];
            if (isset($fieldtype_encode_binary[$fieldtypes[$colnum]])) $col = $fieldtype_encode_binary[$fieldtypes[$colnum]]( $col );
        }
        unset($col);
        if ($resulttype == SQLITE3_ASSOC) $row = array_combine( $fieldnames, $row );
        $rows[] = $row;
    }

    $result->finalize();

    $sqlite->close();

    return $rows;
}

Remark 1: The type of a column is SQLITE3_NULL before any 'fetchArray' and 'false' after last fetched row.

Remark2 : The actual values of SQLITE3_INTEGER, SQLITE3_FLOAT, SQLITE3_TEXT, SQLITE3_BLOB, SQLITE3_NULL are 1, 2, 3, 4, 5.
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.