Ciao ragazzi,
Ho una situazione che non ho mai trovato prima.
Sto usando pdo per connettermi ad un db vertica.
Quando faccio la query da terminale, ottengo tutti i dati richiesti senza nessun problema, ma quando la eseguo con php, mi vengono stampate solo le colonne delle date e tutte le altre sono vuote. Come e' possibile?
$query = "select month_quart as quarter, time::date as date, country.name as country, client.name as
client, client_id_norm as client_id, item_id_def as item_id, sum(total_rev) as total_revenue from daily_data,
date_tab, country_d, clients where item_id != 0 and time = full_date::date and country.id =
country_id and clients.client_id = client_id group by date, client, client_id,
country, item, quarter limit 500;";
$stmt = $conn->prepare($query);
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row){
$quarter = $row[0];
$date = $row[1];
$country = $row[2];
$client = $row[3];
$client_id =$row[4];
$item_id = $row[5];
$total_revenue = $row[6];
//debugging
print_r($row);
echo "<tr><td>$quarter</td><td>$date</td><td>$country</td><td>$client</td><td>$client_id</td><td>$item_id</td><td>$total_revenue</td><td></td></tr>";
//end foreach
}
}
}catch (PDOException $e){
// report error message
echo $e->getMessage();
}
Avete qualche idea su come risolvere?
La tabella viene stampata vuota vuota ad eccezione dei primi due campi (date e quarter). Nessun errore viene riportato. Ovviamente anche l'array $row e' vuoto ad ogni riga. Non so proprio come risolvere, qualsiasi dritta aiuterebbe.
Grazie!
Edit: aggiungo esempio dell'array stampato per ogni riga:
Array ( [quarter] => Feb-Q1 [0] => Feb-Q1 [date] => 2016-02-14 [1] => 2016-02-14 [country] => [2] => [client] => [3] => [client_id] => [4] => [item_id] => [5] => [total_revenue] => [6] => )