This is my first php program!


(The Spy Who Loved Me, starring Roger Moore)



Download 6,9 Mb.
Pdf ko'rish
bet59/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   55   56   57   58   59   60   61   62   ...   69
Bog'liq
PHP

(The Spy Who Loved Me, starring Roger Moore)
The
getCol( )
method returns a single column from the data returned by an SQL
query:
$col = $db->getCol(
SQL
[,
column
[,
values
]]);
The
column
parameter can be either a number (0, the default, is the first column), or
the column name.
,ch08.16110 Page 199 Wednesday, March 13, 2002 11:44 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
200
|
Chapter 8: Databases
For example, this fetches the names of all the Bond movies in the database, ordered
by the year they were released:
$titles = $db->getAll("SELECT title FROM movies ORDER BY year ASC");
foreach ($titles as $title) {
echo "$title\n";
}
Dr No
From Russia With Love
Goldfinger
...
The
getAll( )
method returns an array of all the rows returned by the query:
$all = $db->getAll(
SQL
[,
values
[,
fetchmode
]]);
For example, the following code builds a select box containing the names of the
movies. The ID of the selected movie is submitted as the parameter value.
$results = $db->getAll("SELECT id,title FROM movies ORDER BY year ASC");
echo "";
All the
get*( )
methods return
DB_ERROR
when an error occurs.
Details About a Query Response
Four PEAR DB methods provide you with information on a query result object:
numRows( )
,
numCols( )
,
affectedRows( )
, and
tableInfo( )
.
The
numRows( )
and
numCols( )
methods tell you the number of rows and columns
returned from a
SELECT
query:
$howmany = $response->numRows( );
$howmany = $response->numCols( );
The
affectedRows( )
method tells you the number of rows affected by an
INSERT
,
DELETE
, or
UPDATE
operation:
$howmany = $response->affectedRows( );
The
tableInfo( )
method returns detailed information on the type and flags of fields
returned from a
SELECT
operation:
$info = $response->tableInfo( );
The following code dumps the table information into an HTML table:
$info = $response->tableInfo( );
a_to_table($info);
function a_to_table ($a) {
echo "\n";
foreach ($a as $k => $v) {
,ch08.16110 Page 200 Wednesday, March 13, 2002 11:44 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.

Download 6,9 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   69




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish