function query($sql, $returnType=null) { if($this->prepared == false) { $this->prepare($sql); } //echo "\n SQL call = " . $sql . "\n"; $this->queries[] = $sql; // $this->result = $this->connection->query($sql); D::log("\n" . $sql, 'SQL call'); $this->result = mysql_query($sql, $this->connection); $this->prepared = false; if(!$this->result) { D::stack(); D::log(mysql_error($this->connection), 'SQL Errors'); return false; } $returnArray = array(); /* @todo get rid of this switch and use an array of functions instead. */ if(!isset($returnType)) { return true; } switch ($returnType) { case 'object': if(!is_resource($this->result)) { D::stackTrace(); } while($row = mysql_fetch_object($this->result)) { $returnArray[] = $row; } return $returnArray; break; case 'assoc': while($row = mysql_fetch_assoc($this->result)) { $returnArray[] = $row; } return $returnArray; break; case 'driver': return $this->result; break; case 'raw': return $this->result; break; default: return true; } }