This is the second bit of OOP I'm attempting to do, ever, and I've ran into a snag that I can't seem to get past. Here is my class:
class simpleSelectQuery {
// defining the variables that will be used to build this query
var $table;
var $fields = array();
var $constaints;
var $orderby;
var $limit;
var $query;
function defineVars($define_table, $define_fields, $define_constraints, $define_orderby, $define_limit) {
if($define_table != "") $this -> table = $define_table;
if($define_fields != "") $this -> fields = $define_fields;
if($define_constraints != "") $this -> constraints = $define_constraints;
if($define_orderby != "") $this -> orderby = $define_orderby;
if($define_limit != "") $this -> limit = $define_limit;
}
// creating the query statement
$this -> query = "SELECT ".implode(", ", $this -> fields)." FROM ".$this -> table;
if($this -> constraints != "") $this -> query .= " WHERE ".$this -> constraints;
if($this -> orderby != "") $this -> query .= " ORDER BY ".$this -> orderby."";
if($this -> limit != "") $this -> query .= " LIMIT ".$this -> limit;
// echoing the query to the browser
function printQuery() {
echo $this -> query;
}
}
When I try to include the file, before I even attempt to use the class, I get this error in the browser:
Parse error: parse error, unexpected T_VARIABLE, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in c:\apache\htdocs\enting.com\manage\oop_classes_functions.php on line 22
Line 22 is the "$this -> query = "SELECT ".implode(", ", $this -> fields)." FROM ".$this -> table;" line. I don't see the parse error...
Any ideas?