-
[RESOLVED] Fetch, woof!
Is there anything for when you are retrieving a single record from a db that you can read without having to use the fetch_array? Its only a single record/field so I would assume its still an array.
Do I really have to use ...
PHP Code:
while ($r = fetch_array($rs))
{
$blah = $r['SomeBlahRelatedField'];
}
-
Re: Fetch, woof!
you dont have to use the while loop:
PHP Code:
$res = mysql_fetch_array($query);
echo $res['whatever'];
also, you can just select a single field from the db:
"SELECT `whatever` FROM `mytable`"
-
Re: Fetch, woof!
Yes, I am selecting a single field already as I mentioned which seems to reason that if I had a single record returned (db table primary key disallows dups) that I shouldnt have to use a while loop but is there any simple way to just read the field without the fetch_array is really more the question here.
Would I be able to do a ...
$blah = $rs['SomeBlahRelatedField'];
without using fetch_array? Any other functions like a fetch_item or fetch_record?
-
Re: Fetch, woof!
But that's all fetch_array does: it returns one record.
-
Re: Fetch, woof!
Ok thats true but is it really needed if you already have the resultset in the $rs var?
since that will hold the record could you do like I posted above? Oops it should be $rs and not $r.
-
Re: Fetch, woof!
-
Re: Fetch, woof!
-
Re: Fetch, woof!
because, we said so. lol
I dont think there is a specific reason. It doesn't really make a big impact since you are only pulling 1 column anyway.
-
Re: Fetch, woof!
Umm, phpclamp, when you look at the big picture you will see things differently. One "extra" call by itself is no issue but when you add all the calls on the page it can really bog down a page's loading time. ;)