We have updated WebDataRocks EULA, effective as of April 18, 2024. Learn more about what's changed.

How to use mysql query result with WebDataRocks

Closed

Hi All,
Is there somewhere an example which shows the way to use a mysql query result as a data source for pivot table please ?
Thanks in advance,
 

2 answers

Pedro January 3, 2020

I did the below but i have no result on my page 🙁

Start you					   	<div id="wdr-component">
<?php
$json_data[]=array();

if($stmt->execute()) {
while($res = $stmt->fetchAll(PDO::FETCH_ASSOC)){
$json_data[] = $res;
}
// debug
//var_dump($res);
// debug

} else {
print_r($stmt->errorInfo());
}

echo json_encode($json_data);

?>
</div>
<script>
var pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
report: {
dataSource: {
data:"json_data"
}
}
});

r code here
 
Pedro January 3, 2020

problem solved! 🙂
 
<div id=”wdr-component”></div>
<?php
if($stmt->execute()) {
while($res = $stmt->fetch(PDO::FETCH_ASSOC)){

$json_data[] = array(
“ticket_id” => utf8_encode($res[“xxxxx”]),
“classification” => utf8_encode($res[“xxxxx”]),
“severity” => utf8_encode($res[“xxx”]),
“status” => utf8_encode($res[“xxxx”]),
“product” => utf8_encode($res[“xxxx”]),
“assignee” => utf8_encode($res[“xxxx”]),
“opened” => utf8_encode($res[“xxxxx”]),
“cf_platforme” => utf8_encode($res[“xxxx”]),
“version” => utf8_encode($res[‘xxxxxx’])

);
}
} else {
print_r($stmt->errorInfo());
};
//print json_encode($json_data);
//fermeture de la connexion
$conn=null;

?>
<script>
var json_data = <?php print json_encode($json_data);?>;
var pivot = new WebDataRocks({
container: “#wdr-component”,
toolbar: true,
report: {
dataSource: {
data:json_data
},
 

This question is now closed