PHP Velho Oeste 2024

SQLite3Result::columnName

(PHP 5 >= 5.3.0, PHP 7)

SQLite3Result::columnNameReturns the name of the nth column

Descrierea

public SQLite3Result::columnName ( int $column_number ) : string

Returns the name of the column specified by the column_number. Note that the name of a result column is the value of the AS clause for that column, if there is an AS clause. If there is no AS clause then the name of the column is unspecified and may change from one release of libsqlite3 to the next.

Parametri

column_number

The numeric zero-based index of the column.

Valorile întoarse

Returns the string name of the column identified by column_number.

add a note add a note

User Contributed Notes 1 note

up
-6
david dot barkman13 at gmail dot com
14 years ago
Example:

<?php
   
public function selectAll($table)
    {
       
$results = $this->_dbConn->query("SELECT * FROM $table");
       
$cols = $results->numColumns();
        while (
$row = $results->fetchArray()) {
            for (
$i = 1; $i < $cols; $i++) {
                echo
$results->columnName($i) . ': ';
                echo
$row[$i] . '<br />';
            }
           
//print_r($row);
            //echo 'Username: ' . $row['USERNAME'] . '<br />';
       
}
       
$this->_dbConn->close();
    }
?>
To Top