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

search for in the

sqlite_has_more> <sqlite_fetch_string
Last updated: Fri, 06 Nov 2009

view this page in

sqlite_field_name

(PHP 5, PECL sqlite >= 1.0.0)

sqlite_field_nameRetorna o nome de um campo em particular.

Descrição

string sqlite_field_name ( resource $result , int $indice_campo )

Dado um numero de coluna, indice_campo, retorna o nome do campo no resultado result .



add a note add a note User Contributed Notes
sqlite_field_name
rrf5000 at psu dot edu
22-Jun-2007 08: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, 06 Nov 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites