Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

sqlite_field_name

(PHP 5)

sqlite_field_name -- Возвращает имя указанного поля результата запроса

Описание

string sqlite_field_name ( resource result, int field_index )

Возвращает имя поля результата запроса result с порядковым номером field_index.



add a note add a note User Contributed Notes
sqlite_field_name
rrf5000 at psu dot edu
22-Jun-2007 01: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, 26 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571