如果我能解决这个问题,我会被诅咒的,我已经看了太久了,可能遗漏了一些明显的东西。
变量 table 和 order 没有设置,也没有推送数组中的字段。任何人都可以在这里发现任何东西吗?
页
<?php
$table = new table;
$table->table = "db_firstaid";
$table->order = "aid_date";
$table->field("aid_id","false",NULL);
$table->field("aid_patient","true","[F]");
$table->field("aid_aider","true","[F]");
$table->field("aid_date","false","[F]");
$table->field("aid_time","false","[F]");
$table->table();
?>
班级
<?php
class table{
/* Connect */
private $salt = '#######'
private $user = '#######'
private $pass = '#######'
private $host = '#######'
private $data = '#######'
private $db = '';
private $link = NULL;
private function connect(){
$this->link = mysql_connect($this->host, $this->user, $this->pass);
if(!$this->link){
die("<script type=\"text/javascript\">notyfy({text:'Error, could not connect to server.',type:'error',timeout:7000,});</script>");
}
$this->db = mysql_select_db($this->data,$this->link);
if(!$this->db){
die("<script type=\"text/javascript\">notyfy({text:'Error, could not connect to database.',type:'error',timeout:7000,});</script>");
}
}
private function disconnect(){
mysql_close($this->link);
}
/* Push fields into array */
private $fields = array();
public function field($f,$aes,$t){
return $this->fields[] = array($f,$aes,$t);
}
/* Compile SQL string */
public $table = '';
public $order = '';
private $sql = '';
private function genSQL(){
foreach($this->fields as $f){
if($f[1] == 'true'){
$this->sql = $this->sql . "AES_DECRYPT(".$f[0].",'[SALT]') AS ".$f[0].", ";
}else{
$this->sql = $this->sql . $f[0].", ";
}
}
$this->sql = substr($this->sql,0,-1);
$this->sql = "SELECT ".$this->sql." FROM ".$this->table." ORDER BY ".$this->order;
}
/* Query Database */
private $result = '';
private $number = '';
private function query(){
$this->genSQL();
$this->result = mysql_query($this->sql,$this->link) or die(mysql_error());
$this->number = mysql_num_rows($this->result);
}
/* Echo Table */
public function table(){
$this->connect();
$this->query();
if($this->number > 0){
while($row = mysql_fetch_array($this->result)){
echo "<tr class=\"selectable\">";
//Ignore this bit, yet to build.
echo "</tr>";
}
}
$this->disconnect();
}
}