30, August 2008

storing into vars - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: storing into vars
« previous next »
Pages: [1] Print

Author Topic: storing into vars  (Read 293 times)
Cyberpunk Wannabe
*
Posts: 46
352 credits
Members referred : 0


« on: Apr 24, 2008, 06:22:10 AM »

for storing info into the
Code:
var $var;
i have seen this done both ways and wondered is there a advantage on one over the other?

is it better to do it
Code:
$this->zname = mysql_result($zinfo_res, 0, "name");
or
Code:
$obj = mysql_fetch_object($zinfo_res);
$this->zname = $obj->name;
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 8029
41131 credits
Members referred : 3



« Reply #1 on: Apr 24, 2008, 07:48:39 AM »

Using class variables is good only if you are going to reuse that data in many functions of the class. Otherwise it looks more like spending too much memory.

Trial and Error my two best teachers Cool
Join us @ facebook Visit through proxy

Last blog : MIA - Where Nick and Tim
Cyberpunk Wannabe
*
Posts: 46
352 credits
Members referred : 0


« Reply #2 on: Apr 24, 2008, 09:23:27 PM »

yeah the data is going to be used in about 3-4 functions currently, but is there a benefit for using one of them styles to store the data or the other?
Nikolas' Servant Child
*
Posts: 30
184 credits
Members referred : 0


« Reply #3 on: Apr 25, 2008, 11:31:29 AM »

Use mysql_fetch_object if you want the whole set of column data to stick around as a group for processing now or later. Use mysql_result if you only want specific columns, or if you want to process the values in PHP (rather than in SQL) before constructing your object.
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7710
Tags : php vars fetch result Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: storing into vars
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Aug 30, 2008, 12:27:24 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 36.176
Total Topics: 7.461
Total Members: 3.860
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: realmadvert

35 Guests, 5 Users online :

17 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.