Object or Array??

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

    Object or Array??

    Hello there...

    I have a little issue here....

    Which one is better(I think object) but would like to hear from someone more
    experienced....

    class Persons
    {
    var $name;
    var $comments;
    var $thoughts;
    var $email;

    some functions.....
    }

    object in array:

    while($line = $result->FetchRow()) //using ADODB
    {
    $person[$line['id']] = &new Persons;
    $person[$line['id']]->name = $line['name'];
    $person[$line['id']]->thoughts = $line['thoughts'];
    $person[$line['id']]->email = $line['email'];
    $person[$line['id']]->comments = $line['comments'];
    }

    or plain array:

    while($line = $result->FetchRow())

    $person[$line['id']]=Array("name"=> $line['name'],"thoughts"=>$l ine['thoughts
    '],"email"=>$l ine['email'],"comments"=>$l ine['comments']);

    thanx and respect....

    p.




  • Nikolai Chuvakhin

    #2
    Re: Object or Array??

    "point" <point@caanNOSP AMproduction.co m> wrote
    in message news:<bjev3q02v gv@enews2.newsg uy.com>...[color=blue]
    >
    > Which one is better (I think object) but would like to hear
    > from someone more experienced....[/color]

    Define "better". Better for what? Reusability? Go with objects.
    Performance? Stick with arrays and stop using abstraction layers.

    Cheers,
    NC

    Comment

    • point

      #3
      Re: Object or Array??

      Thanx for your oppinions....

      I'm sticking with objects just wanted to hear your oppinions....

      In my oppinion objects are more close(although more abstract) to human way
      of thinking than the procedural programing.....

      respect....



      "point" <point@caanNOSP AMproduction.co m> wrote in message
      news:bjev3q02vg v@enews2.newsgu y.com...[color=blue]
      > Hello there...
      >
      > I have a little issue here....
      >
      > Which one is better(I think object) but would like to hear from someone[/color]
      more[color=blue]
      > experienced....
      >
      > class Persons
      > {
      > var $name;
      > var $comments;
      > var $thoughts;
      > var $email;
      >
      > some functions.....
      > }
      >
      > object in array:
      >
      > while($line = $result->FetchRow()) //using ADODB
      > {
      > $person[$line['id']] = &new Persons;
      > $person[$line['id']]->name = $line['name'];
      > $person[$line['id']]->thoughts = $line['thoughts'];
      > $person[$line['id']]->email = $line['email'];
      > $person[$line['id']]->comments = $line['comments'];
      > }
      >
      > or plain array:
      >
      > while($line = $result->FetchRow())
      >
      >[/color]
      $person[$line['id']]=Array("name"=> $line['name'],"thoughts"=>$l ine['thoughts[color=blue]
      > '],"email"=>$l ine['email'],"comments"=>$l ine['comments']);
      >
      > thanx and respect....
      >
      > p.
      >
      >
      >
      >[/color]


      Comment

      Working...