Magento Expert Forum - Improve your Magento experience

Results 1 to 8 of 8

What is the difference between mysql_fetch_object() and mysql_fetch_array()?

  1. #1

  2. The Following User Says Thank You to kajal For This Useful Post:

    anneroberts (30-08-2017)

  3. #2
    Junior Member
    Join Date
    Oct 2016
    Posts
    984
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default

    1) mysql_fetch_array : Returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), [by] using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).

    2) mysql_fetch_row: Returns a numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows. mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

  4. #3
    Junior Member
    Join Date
    Mar 2017
    Location
    Delhi
    Posts
    244
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    mysql_fetch_array: returned a row from recordset as a numeric and/or associative array.

    mysql_fetch_row: returned a row from recordset as a numeric array.

  5. #4
    Junior Member fay_khattak's Avatar
    Join Date
    Jan 2016
    Location
    Karachi, Pakistan
    Posts
    50
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    The official documentation is pretty clear on this, have you looked at it?

    mysql_fetch_array returns an array of strings that corresponds to the fetched row, or FALSE if there are no more rows. The type of returned array depends on how result_type is defined. By using MYSQL_BOTH (default), you'll get an array with both associative and number indices. Using MYSQL_ASSOC, you only get associative indices (as mysql_fetch_assoc() works), [by] using MYSQL_NUM, you only get number indices (as mysql_fetch_row() works).

    However, mysql_fetch_row returns a numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows. mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0.

  6. #5
    Expert
    Join Date
    Mar 2016
    Location
    india
    Posts
    570
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Mysql_fetch_object returns the result from the database as objects while mysql_fetch_array returns result as an array. This will allow access to the data by the field names.

  7. #6
    Junior Member
    Join Date
    Sep 2018
    Location
    United Kingdom
    Posts
    156
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    Speed-wise, the capacity is indistinguishable to mysql_fetch_array(), and nearly as fast as mysql_fetch_row() (the thing that matters is immaterial). mysql_fetch_object() is like mysql_fetch_array(), with one contrast - an article is returned, rather than an exhibit.

  8. #7
    Junior Member
    Join Date
    Sep 2018
    Location
    Oman, Muscat
    Posts
    2,084
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Default

    The line is returned as a cluster. Each outcome section is put away in a cluster counterbalance, beginning at balance 0. A significant number of the php programming novices get confounded about mysql_fetch_array(), mysql_fetch_row(), mysql_fetch_assoc() and mysql_fetch_object() capacities, however these capacities plays out a comparative procedure.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •