Я сталкиваюсь с проблемой в MySQL, может кто-нибудь помочь мне решить эту проблему.
Вопрос: mysql_num_fields () ожидает, что параметр 1 будет объектом ресурса, заданным в (opencart 2.1.0.1)
public function export () {
$output = "";
$table = "app_feedback"; // Enter Your Table Name$query = "SELECT ap.*,sr.name as ShowRoomName,CONCAT_WS(' ', sr.address1, sr.address2,sa.showroom_area_name,sc.showroom_city_name,ss.showroom_state_name,'-',sr.pincode) AS ShowroomAddress FROM ".DB_PREFIX."app_feedback ap LEFT JOIN " . DB_PREFIX . "showroom sr ON (ap.showroom = sr.showroom_id) LEFT JOIN " . DB_PREFIX . "showroom_area sa ON (sr.showroom_area_id = sa.showroom_area_id) LEFT JOIN " . DB_PREFIX . "showroom_city sc ON (sr.showroom_city_id = sc.showroom_city_id) LEFT JOIN " . DB_PREFIX . "showroom_state ss ON (sr.showroom_state_id = ss.showroom_state_id)";
if(!empty($this->request->get['date_from'])&&!empty($this->request->get['date_to'])){
$date_from = $this->request->get['date_from'];
$date_to = $this->request->get['date_to'];
$time_from = $this->request->get['time_from'];
if(empty($time_from)){
$time_from = '00:00';
}
$time_to = $this->request->get['time_to'];
if(empty($time_to)){
$time_to = '23:59';
}
// $query .=" WHERE DATE(date)>= '".$date_from."' AND DATE(date)<='".$date_to."'";
$query .=" WHERE date BETWEEN '".$date_from. ' '.$time_from.":00' AND '".$date_to.' '.$time_to.":00'";
}
$sql = mysql_query($query);
$columns_total = mysql_num_fields($sql);
// Get The Field Name
for ($i = 0; $i < $columns_total; $i++) {
$heading = mysql_field_name($sql, $i);
if($heading!='showroom')
{
$output .= '"'.$heading.'",';
}
// $output .= '"'.$heading.'",';
}
$output .="\r\n";
// Get Records from the table
while ($row = mysql_fetch_array($sql)) {
for ($i = 0; $i < $columns_total; $i++) {
// $output .='"'.$row["$i"].'",';
if($i!=16){
$values=str_replace('amp;', "", $row["$i"]);
$output .='"'.$values.'",';
}
}
$output .="\r\n";
}
// Download the file$filename = "feedback.csv";
header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
echo $output;
}
Других решений пока нет …