Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: storing vs not

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    storing vs not

    what is more efficient?

    printing $database[somevar] a couple times in your code or manipulting it , such as multiplying it by 2, or storing it under $myvar and using $myvar?

    or is there no difference?

  • #2
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    844
    Thanks
    15
    Thanked 9 Times in 9 Posts
    In my honest opinion I find no real difference, but I'm sure you will get the odd guy that will argue that it makes a difference. I however found that certain operations didn't work with the array value but did with the regular variable.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #3
    New Coder
    Join Date
    May 2006
    Location
    California
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well depends on the situation you are using it, if you have an array of information and need all of them to be multiplied by 2 or need every other one multiplied by 2 you would use an array with a for loop. It also really makes no difference ans is more a personal preference than anything else as dniwebdesign stated.

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    alright cool! thanks saved me some trouble :P

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    I hate code like ...
    PHP Code:
    <?php
    $r
    =mysql_fetch_assoc($q);
    $var1 =$r['var1'];
    $var2=$r['var2'];
    //.... etc etc//
    $var20=$r['var20'];
    ?>
    I don't see the point unless one really needs the typing practice ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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