[thelist] php/mysql - two consecutive select statements

Dave Preston caffiend at simianbrotherhood.org
Fri Nov 16 10:05:17 CST 2001


That's true, but using mysql_fetch_obj avoids the hassle of breaking
anything. If you update the pages first they break because they don't
have the appropriate fields in the db, if you update the schema first
you run a chance of messing up your variable assignment in the script.

I just consider it a cleaner way to work and make future expansion
easier.


-d (coffee slowly working it's way into system, coherent?)

On Fri, Nov 16, 2001 at 11:01:51AM -0500, Jay Greenspan wrote:
> 
> On Friday, November 16, 2001, at 10:18 AM, Dave Preston wrote:
> 
> > Wow, that's pretty scary.. I'd *strongly* urge you to ditch using list
> > and use mysql_fetch_obj instead of mysql_fetch_row. The main reason
> > being that if you ever change your schema, you'll be screwed if you
> > forget to update any of your php scripts.
> 
> Dave, I'm not sure what you mean here.
> 
> > $obj = mysql_fetch_object($job_query, MYSQL_ASSOC);
> > $client_id = $obj->client_id;
> 
> Um, OK, but if the schema changes, you'll still have to update your 
> script. I mean,
> if the schema changes, the query will change. If $client_id is in the 
> result it can
> just as easily be assigned to a scalar variable with 
> list()=mysql_fetch_array() as it can with
> mysql_fetch_object(). Right? It seems to me that this is an additional 
> step which
> requires a bit (really a trivial amount) more memory allocation but 
> doesn't really
> get you anything unless you're a huge fan of PHP OO syntax.
> 
> It's quite possible that I'm just too stupid to see your point. Would 
> you mind clarifying
> for me?
> 
> -j
> 
> 
> 
> ---------------------------------------
> For unsubscribe and other options, including
> the Tip Harvester and archive of TheList go to:
> http://lists.evolt.org Workers of the Web, evolt ! 
> 




More information about the thelist mailing list