//If you have a working PHPLIB installed, you might want to enable all
// of the session-related lines in this file, as that will make several
// additional features possible (such as variable number of conditions and
// the next/prev buttons)
//page_open( array("sess" => "Poe_Session" ));
require("c_timer.inc");
$timer = new c_Timer;
$timer->start();
// setup_queries provides the gobal function getSelectQuery which is used
// by the various sql_form objects - see sqlforms.inc
require( "setup_queries.inc" );
// filter provides the function getSelectFilter() which is used by
// some of the sql_form objects as well
require( "filter_queries.inc" );
require "SQL_Select.inc";
require "special_query.inc";
// When we hit this page the first time,
// there is no $sq.
if (!isset($sq))
{
$sq = new Special_Query( "setup_form.inc", "form_layout.ihtml"); // We make one
$sq->conditions = 2; // ... with TWO conditions (at first)
$sq->variable = "on"; // ... # of conditions is variable
$sq->lang = "easy_en"; // ... in EASY TO UNDERSTAND English, please
$sq->method = "GET";
//$sess->register("sq"); // and don't forget this!
}
$user = new SQL_Cond( "user", "lastname", "<>", "'test'" );
$user2 = new SQL_Cond( "user", "userid", "=", "student", "userid" );
$user_check = $user->sand($user2);
$select_all = new SQL_Cond( "student", "studentid", ">", "0" );
$Sql = new SQL_Select( $select_all->sand( $user_check ) );
$sq->default_sql = $Sql;
$sq->what_to_select = "student.studentid";
// In any case we must display that form now. Note that the
// "x" here and in the call to $q->where must match.
// Tag everything as a CSS "query" class.
//strings that begin with s_ are names of SQL_Select objects and are
//defined in setup_queries.inc
$op = array("s_schoolname" => "School",
"s_schoolgpa" => "GPA",
"s_schoolmajor" => "Major",
"s_schoolmajortype"=>"Area of study",
"s_schooldegree" => "Degree",
"s_schoolgrad" => "Graduation year",
"s_satscore" => "SAT score",
"s_lsatscore" => "LSAT score",
# "s_actname" => "Extra-curricular organization",
"s_acttype" => "Activity",
"s_compname" => "Skill (Computer)",
"s_progname" => "Skill (Programming languages)",
"s_artname" => "Skill (Other)",
"s_langfluent" => "Foreign language (fluent)",
"s_langprof" => "Foreign language (proficient)",
"s_regionpref" => "Preferred geographic region",
"s_country" => "Current location (Country)",
"s_state" => "Current location (State)",
"s_sectorpref" => "Preferred industry sector",
"s_sector"=> "Industry sector experience",
"s_fullname" => "Name"
);
$sq->form("x", $op, "query");
// When we hit that page a second time, the array named
// by $base will be set and we must generate the $query.
// in this case, the data from the form is all posted to $x
if (isset($x))
{
// extract the data from $x into a SQL_Select object
$Sql = $sq->getSelect("x", 1 );
$Sqlcount = $sq->getCountSelect("x", 0);
$Sqlcount->limit = 0;
$Sql->group = 0;
$Sqlcount->group = 0;
}
if (isset($x) && $Sql)
{
// at this point we have 2 different SQL_Select objects
// one to get the count and one to do the query. This is sub-optimal
printf( "\nTo get the count I would query:
%s
\n",
$Sqlcount->toString() );
/* like this:
$result = $db->query( $Sqlcount->toString() );
$db->next_record();
$num_results = $db->num_rows();
*/
printf( "\nTo get the actual results, I would query:
%s
\n",
$sql_string = $Sql->toString() );
/* like this:
$result = $db->query( $sql_string );
$query_results = $db->num_rows();
$sq->query_count = $query_results;
if( $num_results )
{
if( $perm->have_perm( "internal" ) )
{
$result_string = sprintf( "%d to %d", $sq->iFirst+1, min( 0+$num_results, $sq->iLast ));
$result_string .= " (of $num_results)";
}
}
else
{
$result_string = "No candidates matching your query";
}
*/
}
/*
if I wanted to use this package with EnzymeTemplates, I would do something
like this:
while( $db->next_record() )
{
$sid = $db->f( "studentid" );
$stud = new Student( $sid );
$stud->printShort();
$count++;
}
*/
$timer->stop();
echo "Time elapsed: ".$timer->elapsed()."
";
//page_close();
?>