28, May 2012

storing into vars - webmaster forum

 
Webdigity webmaster forums
[ 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
Instabuck - The easy way to sell digital products online

Author Topic: storing into vars  (Read 1078 times)
OMG!I am geek
**
Posts: 53
406 credits
Members referred : 0


« on: Apr 24, 2008, 05: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: 5799
46391 credits
Members referred : 3



« Reply #1 on: Apr 24, 2008, 06: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 or twitter

Last blog : Butterfly Marketing 2.0
OMG!I am geek
**
Posts: 53
406 credits
Members referred : 0


« Reply #2 on: Apr 24, 2008, 08: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?
Cyberpunk Wannabe
*
Posts: 34
208 credits
Members referred : 0


« Reply #3 on: Apr 25, 2008, 10: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....

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?
May 28, 2012, 08:09:09 pm





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!






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