Re: Including declare statements that contain variables

From: Date: Wed, 14 Nov 2001 18:49:45 +0000
Subject: Re: Including declare statements that contain variables
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-74630@lists.php.net to get a copy of this message
Jim Lucas <or001@bend.com> wrote in message news:012301c16d3a$6def13c0$96def5cc@bendcom... > Here are a few pointers to make it run just a little faster also. > > don't extract the entire $GLOBALS array. just use the $var that you need. > function GetData($Query) > { > return(mysql_query($Query, $GLOBALS[db_conn])); > } The problem with this approach is that I do not know ahead of time which GLOBALS I will need (other than $db_conn). For instance, once query may depend of the $ClassID and $Attendance variables while another depends on the $StudentID and $Grade variables > > why are you using a define to set an SQL query string? I am using define to set SQL query strings because there are a limited number (30 or so) of queries used by the application, but they are used in different contexts. So, for example, I may have: "SELECT FirstName, LastName, Grade, Attendance FROM Students, Classes WHERE Students.StudentID = Classes.StudentID AND ClassID = $Class" defined as StudentsByClass. I can then pass the function the constant and use it in different situations. For example: PrintMenu("Students",GetData(StudentsByClass)); will print a menu of student names whereas: PrintAttendance(GetData(StudentsByClass)); would print an attendance report Fred

« previous php.general (#74630) next »