/ Published in: PHP
Expand |
Embed | Plain Text
function list_free_dataset() { $this->list['has_limit'] = 0; $this->list['order'] = ''; $this->list['special_select_fields'] = ''; } function list_set_limit($start, $limit) { $this->list['has_limit'] = 1; $this->list['start_limit'] = $start; $this->list['stop_limit'] = $limit; } function list_set_order($order) { $this->list['order'] = $order; } function list_set_filter($filter) { } function list_set_additional_tables($tables) { } function list_set_join_conditions($condition) { } function list_set_special_select_fields($fields) { $this->list['special_select_fields'] = $fields; } $SQL = "SELECT "; // SET SELECT FIELDS if ($this->list['special_select_fields']) $SQL .= $this->list['special_select_fields']." "; else $SQL .= "* "; if (!$this->tablename) return false; $SQL .= "FROM ". $this->tablename; // SET DB NAMES if ($this->list['additional_tables']) { foreach ($this->list['additional_tables'] as $table) { $SQL .= ", $table "; } } // SET JOIN CONDITIONS if ($this->list['join_conditions']) { foreach ($this->list['join_conditions'] as $join) { if (!$condition) { $separator = " WHERE"; $condition++; } else { $separator = " AND"; } $SQL .= "$separator $join"; } } // SET FILTER CONDITION if ($this->list['filter']) { foreach ($this->list['filter'] as $filter) { if (!$condition) { $separator = " WHERE"; $condition++; } else { $separator = " AND"; } $SQL .= "$separator $filter"; } } // SET ORDER CONDITION if ($this->list['order']) $SQL .= " ORDER BY ".$this->list['order']; // SET LIMIT CONDITION if ($this->list['has_limit']) $SQL .= " LIMIT ".$this->list['start_limit'].", ".$this->list['stop_limit']; //echo "SQL: $SQL<br />"; } return $list; } return 0; }
You need to login to post a comment.
