473,320 Members | 2,027 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Different between mysql_fetch_object and mysql_fetch_assoc/array?

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.

Oct 5 '05 #1
2 3809
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.
Oct 5 '05 #2
Ha!

Same to you. I like to use (DB)_fetch_object with same reason!

Anyway, thanks for your advise.

Oct 6 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Robert Oschler | last post by:
What is the object returned by a call to mysql_fetch_object()? Is it an array, a class, what? I know I can access fields from the result object using the "->" operator, but how can I...
2
by: ameshkin | last post by:
I'm having all kinds of visual problems using dreamweaver's built in query builder. I have 4 different categories. Right. I want to show ten records from each category of items in a mysql...
3
by: Paul Lautman | last post by:
Are there any benefits to using mysql_fetch_object() instead of mysql_fetch_assoc()?
3
by: smythe70 | last post by:
How do mysql_query() and mysql_fetch_assoc() actually work? When I submit a query to a MySQL database it goes away, works out what I requested and throws it back at me. When I submit a query...
1
by: billkirim | last post by:
hi guys.. can anyone help me with that staff? here is my code.. $cart = $_SESSION; $action = $_GET; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET;
2
by: phattymatty | last post by:
I am having trouble getting this loop to do what I would like it to. I need to display information from a multidimensional array in order. The order has already been sorted in the array using a...
1
by: bytesFTW99 | last post by:
Ok I have a problem! i have a mysql_fetch_assoc that does not recognize the NULL value of the column. however, i want this null to be picked up so i can use it. how can i go about doing that? ...
2
by: bytesFTW99 | last post by:
i have an array that is pulling down information from a database that has null values. how can a get the mysql_fetch_assoc to recognize this null value as just empty space to fill in a form as white...
2
by: poreko | last post by:
I am connecting to my database using Object oriented PHP. My query is returning results but at the end of my table,at the bottom of the page I keep having this error when I run my program: Warning:...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.