PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

sqlite_has_more> <sqlite_fetch_string
Last updated: Fri, 27 Jun 2008

view this page in

sqlite_field_name

SQLiteResult->fieldName

SQLiteUnbuffered->fieldName

(No version information available, might be only in CVS)

SQLiteUnbuffered->fieldName — Returns the name of a particular field

Description

string sqlite_field_name ( resource $result , int $field_index )

Object oriented style (method):

SQLiteResult
string fieldName ( int $field_index )
SQLiteUnbuffered
string fieldName ( int $field_index )

Given the ordinal column number, field_index , sqlite_field_name() returns the name of that field in the result set result .

Parameters

result

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

field_index

The ordinal column number in the result set.

Return Values

Returns the name of a field in an SQLite result set, given the ordinal column number; FALSE on error.

The column names returned by SQLITE_ASSOC and SQLITE_BOTH will be case-folded according to the value of the sqlite.assoc_case configuration option.



add a note add a note User Contributed Notes
sqlite_field_name
rrf5000 at psu dot edu
22-Jun-2007 02:03
While working with SQLite using its object-oriented mode, I found need to display a column/field name without knowing what it was in advance.  I couldn't find any examples on the Internet, just this document.  So, for anyone who happens to need to do this, here's an example.

<?php

$db
= "db/database.sqlite";

// create new database (OO interface)
$dbo = new SQLiteDatabase("$db");

// create table foo and insert sample data
$dbo->query("
 CREATE TABLE foo(id INTEGER PRIMARY KEY, name CHAR(255));
 INSERT INTO foo (name) VALUES('Ilia1');
 INSERT INTO foo (name) VALUES('Ilia2');
 INSERT INTO foo (name) VALUES('Ilia3');
"
);

$query = "SELECT * FROM foo;";

$result = $dbo->query($query) or die("Error in query");

echo
"
<table border='1' cellpadding='10'>
 <tr>
  <td>"
.$result->fieldName(0)."</td>
  <td>"
.$result->fieldName(1)."</td>
 </tr>"
;

// iterate through the retrieved rows
while ($result->valid()) {
 
// fetch current row
 
$row = $result->current();
  echo
"
 <tr>
  <td>"
.$row[0]."</td>
  <td>"
.$row[1]."</td>
 </tr>"
;
 
// proceed to next row
 
$result->next();
}

echo
"</table>";

?>

sqlite_has_more> <sqlite_fetch_string
Last updated: Fri, 27 Jun 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites