mysql_fetch_assoc vs mysql_fetch_object

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul Lautman

    #1

    mysql_fetch_assoc vs mysql_fetch_object

    Are there any benefits to using mysql_fetch_obj ect() instead of
    mysql_fetch_ass oc()?


  • Erwin Moller

    #2
    Re: mysql_fetch_ass oc vs mysql_fetch_obj ect

    Paul Lautman wrote:
    [color=blue]
    > Are there any benefits to using mysql_fetch_obj ect() instead of
    > mysql_fetch_ass oc()?[/color]

    mysql_fetch_ass oc()?returns an assosiative array, mysql_fetch_obj ect()
    returns an object that contains the same row-information (name values).

    So the syntax used to get the infortion out differs, not the actual content.
    mysql_fetch_ass oc()
    use
    $row["userid"]

    mysql_fetch_obj ect()
    use
    $row->userid

    So the benefit would be that if you want an object, you use
    mysql_fetch_obj ect().

    I am afraid there is nothing more to it.

    Regards,
    Erwin Moller

    Comment

    • Steffen

      #3
      Re: mysql_fetch_ass oc vs mysql_fetch_obj ect

      Hi Paul[color=blue]
      > Are there any benefits to using mysql_fetch_obj ect() instead of[/color]
      mysql_fetch_ass oc()?
      AFAIK there is only one major difference.
      mysql_fetch_ass oc returns an array, mysql_fetch_obj ect() returns an
      object that contains the same values as the array.

      mysql_fetch_ass oc()
      $row["userid"]

      mysql_fetch_obj ect()
      $row->userid

      Regards
      Steffen Jahr

      Comment

      • Paul Lautman

        #4
        Re: mysql_fetch_ass oc vs mysql_fetch_obj ect

        Steffen wrote:[color=blue]
        > Hi Paul[color=green]
        > > Are there any benefits to using mysql_fetch_obj ect() instead of[/color]
        > mysql_fetch_ass oc()?
        > AFAIK there is only one major difference.
        > mysql_fetch_ass oc returns an array, mysql_fetch_obj ect() returns an
        > object that contains the same values as the array.
        >
        > mysql_fetch_ass oc()
        > $row["userid"]
        >
        > mysql_fetch_obj ect()
        > $row->userid
        >
        > Regards
        > Steffen Jahr[/color]

        Yes I know the difference. To me there are adantages of using
        mysql_fetch_ass oc() in that you can use the array functions such as
        array_walk and uasort(). I was wondering if mysql_fetch_obj ect() brought any
        advantages that mysql_fetch_ass oc() did not have?


        Comment

        Working...