This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet55/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   51   52   53   54   55   56   57   58   ...   69
Bog'liq
PHP

196
|
Chapter 8: Databases
Storing the row
The
fetchInto( )
method also gets the next row, but stores it into the array variable
passed as a parameter:
$success = $result->fetchInto(
array
, [
mode
]);
Like
fetchRow( )
,
fetchInto( )
returns
NULL
if there is no more data, or
DB_ERROR
if an
error occurs.
The idiom to process all results looks like this with
fetchInto( )
:
while ($success = $result->fetchInto($row)) {
if (DB::isError($success)) {
die($success->getMessage( ));
}
// do something with the row
}
Inside a row array
Just what are these rows that are being returned? By default, they’re indexed arrays,
where the positions in the array correspond to the order of the columns in the
returned result. For example:
$row = $result->fetchRow( );
if (DB::isError($row)) {
die($row->getMessage( ));
}
var_dump($row);
array(3) {
[0]=>
string(5) "Dr No"
[1]=>
string(4) "1962"
[2]=>
string(12) "Sean Connery"
}
You can pass a
mode
parameter to
fetchRow( )
or
fetchInto( )
to control the format of
the row array. The default behavior, shown previously, is specified with
DB_
FETCHMODE_ORDERED
.
The fetch mode
DB_FETCHMODE_ASSOC
creates an array whose keys are the column
names and whose values are the values from those columns:
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
if (DB::isError($row)) {
die($row->getMessage( ));
}
var_dump($row);
array(3) {
["title"]=>
string(5) "Dr No"
["year"]=>
,ch08.16110 Page 196 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   ...   51   52   53   54   55   56   57   58   ...   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