You are here: Re: Different between mysql_fetch_object and mysql_fetch_assoc/array? « PHP Programming Language « IT news, forums, messages
Re: Different between mysql_fetch_object and mysql_fetch_assoc/array?

Posted by Marcus on 11/24/19 11:28

Alucard wrote:
> Hi all.
>
> I am a newbie in PHP. Recently I found that there are mainly two ways
> to fetch mysql(or other DB) data: by object or by array.
>
> What is the main differences between them? Will the server use more
> resources (just my thought) when fetching by object? Or any other
> reasons?
>
> Thanks in advance for advises.
>

In my experience there is no difference between the two. I would guess
that if you got down to specifics fetching by array *might* be a bit
faster, but I think it would be so small it wouldn't affect your script
at all.

The difference is after you run your query with either:

$row = mysql_fetch_object($result) or
$row = mysql_fetch_array($result)

you would reference your fields by

$row->field or
$row[index]

respectively. I like using mysql_fetch_object because it seems natural
to me to reference with ->field, but it's up to you.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация