Easy A
Would you like to react to this message? Create an account in a few clicks or log in to continue.


 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log inLog in  

Share
 

 fetch array vs fetch assoc

View previous topic View next topic Go down 
AuthorMessage
Escape
Member
Member
Escape

Posts : 16
Join date : 2011-03-09

fetch array vs fetch assoc Empty
PostSubject: fetch array vs fetch assoc   fetch array vs fetch assoc EmptyThu Jun 23, 2011 7:10 am

Hi all

Are these two essentially(maybe exactly) doing the same thing or is there a difference.

I'm trying to work out if it's just a matter of choice when to use one and not the other.
Code:

//from book, learning Mysqli
$row = $result->fetch_array(MYSQLI_ASSOC)

//what i've seen:
$row = $result->fetch_assoc(); 

LT :D
Back to top Go down
Knowledge
Member
Member
Knowledge

Posts : 21
Join date : 2011-03-09

fetch array vs fetch assoc Empty
PostSubject: Re: fetch array vs fetch assoc   fetch array vs fetch assoc EmptyThu Jun 23, 2011 7:11 am

They are functionally the same. You can get more information from the manual page.
Back to top Go down
Escape
Member
Member
Escape

Posts : 16
Join date : 2011-03-09

fetch array vs fetch assoc Empty
PostSubject: Re: fetch array vs fetch assoc   fetch array vs fetch assoc EmptyThu Jun 23, 2011 7:12 am

Thanks knowledge

Yep a bit more reading

OK
came across this on the other page

mysql_fetch_assoc() is equivalent to calling mysql_fetch_array() with MYSQL_ASSOC for the optional second parameter. It only returns an associative array.


Back to top Go down
CaptainCop
Member
Member
avatar

Posts : 14
Join date : 2011-03-09

fetch array vs fetch assoc Empty
PostSubject: Re: fetch array vs fetch assoc   fetch array vs fetch assoc EmptyThu Jun 23, 2011 7:13 am

fetch_array can return an indexed array, an associative array or both while fetch_assoc will return only an associative array.

Personally I prefer to use mysql_fetch_assoc() because the keys in the array are the actual column names returned by the original sql query.

mysql_fetch_array returns both types of arrays by default which is a waste imo unless you need both for some reason.
Back to top Go down
Sponsored content




fetch array vs fetch assoc Empty
PostSubject: Re: fetch array vs fetch assoc   fetch array vs fetch assoc Empty

Back to top Go down
 

fetch array vs fetch assoc

View previous topic View next topic Back to top 
Page 1 of 1

 Similar topics

-
» get array value
» Display image in an array format
» Array element display, newbie question
» Can you expand an array of N to fill N functional arguments?

Permissions in this forum:You cannot reply to topics in this forum
Easy A :: fetch array vs fetch assoc Edit-trash Useless :: Trash-