php with Oracle
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



php with Oracle Expand / Collapse
Author
Message
Posted 3/28/2008 5:22:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/27/2008 7:53:22 AM
Posts: 6, Visits: 16
Hi all

I have various tables in Oracle and wish to generate some basic column graphs. I started hacking the BasicDBExample.php changing all the mysql_query etc for the oracle (oci) equivalents to pull the data form the database. It failed due to the addDataFromDatabase function. I looked this up in the FusionCharts_Gen.php file and it is all mysql based stuff

Does anybody have any examples or hacked versions of this file that work with Oracle.

Thanks
Clem
Post #5310
Posted 3/31/2008 1:32:35 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Today @ 5:38:52 AM
Posts: 884, Visits: 1,420
Hi,

We have hacked the FusionCharts_Gen.php to support Oracle. Could you please check and revert back as you test with this?

Please note that you need to create Oracle connection and execute statement before passing it to the methods like addDataFromDatabase. These methods would only use oci_fetch_array() to retrieve data.

Regards,

Sudipto Choudhury
FusionCharts Team


  Post Attachments 
FusionCharts_Gen.php.txt (6 views, 60.07 KB)

Post #5377
Posted 3/31/2008 9:55:14 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/27/2008 7:53:22 AM
Posts: 6, Visits: 16
Hi there

Thanks for the updated file. Finally managed to get it to work.... Below is a modified example... Basically OCI only accepts uppercase.

$conn;

# Create pie 3d chart object using FusionCharts PHP Class
$FC = new FusionCharts("Pie3D","650","450");

# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");

//Store chart attributes in a variable for ease of use
$strParam="caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30; showBorder=1;showNames=1;formatNumberScale=0;numberSuffix= Units;decimalPrecision=0";

# Set chart attributes
$FC->setChartParams($strParam);


// Fetch all factory records usins SQL Query
//Store chart data values in 'total' column/field and category names in 'FactoryName'
$strQuery = "select a.FactoryID, b.FactoryName FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.FactoryName";
$stid = oci_parse($conn,$strQuery);
$result = oci_execute($stid);

//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database

if ($result) {
$FC->addDataFromDatabase($stid, "TOTAL", "FACTORYNAME");
}
oci_close($conn);

# Render the chart
$FC->renderChart();
Post #5389
Posted 4/9/2008 4:47:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 5/27/2008 7:53:22 AM
Posts: 6, Visits: 16
The previously attached Fusionchart_gen.php file contains oci commands for php 5 only. Below is a snippet for 2 of the functions I had to re-write to be compatible with php4.

# Function addDatasetsFromDatabase adding dataset and set element by Oracle recordset
function addDatasetsFromDatabase($query_result, $ctrlField, $valueField,$datsetParamArray="",$LinkPlaceHolder=""){

# Initialize variables
$paramset="";
$tempContrl="";
if(is_array($datsetParamArray)==false){
$datsetParamArray=array();
}

# Calculate total no of array elements in datsetParamArray
$arrLimit=count($datsetParamArray);
$i=1;
$tempParam="";
# fetching recordset till eof
while(ocifetchinto($query_result, &$row, OCI_ASSOC)){
# Creating Control break depesqnding on ctrlField
# if ctrlField value change then dataset will be Generate
if ($tempContrl!=$row[$ctrlField]){
if($i<=$arrLimit){
$tempParam = $datsetParamArray[$i-1];
}else{
$tempParam="";
}
# Adding Dataset
$this->addDataset($row[$ctrlField],$tempParam);
$tempContrl=$row[$ctrlField];
$i++;
}
# Generating URL link
if($LinkPlaceHolder==""){
$paramset="";
}else{
# Generating URL link from getLinkFromPattern
$paramset="link=" . urlencode($this->getLinkFromPattern($row,$LinkPlaceHolder));
}
# Adding set into dataset
$this->addChartData($row[$valueField], $paramset, "");
}
}

# addDataFromDatabase funcion take 5 parameter like query_result, label field, value field
# and initialize dataset variables and link
function addDataFromDatabase($query_result, $db_field_ChartData,$db_field_CategoryNames="", $strParam="",$LinkPlaceHolder=""){

$paramset="";
# fetching recordset till eof
while(ocifetchinto($query_result,&$row,OCI_ASSOC)){

if($LinkPlaceHolder==""){
$paramset="";
}else{
# Getting link
$paramset="link=" . urlencode($this->getLinkFromPattern($row,$LinkPlaceHolder));
}
if ($strParam=""){
$strParam=$paramset;
}else{
$strParam .= ";" . $paramset;
}

# covert to set element and save to $partXML
if($db_field_CategoryNames==""){
$data=@$row[$db_field_ChartData];
if($strParam!="")
$this->addChartData($this->encodeSpecialChars($data),$strParam,"" );
else
$this->addChartData($this->encodeSpecialChars($data));
}
else{
$data=@$row[$db_field_ChartData];
$label=@$row[$db_field_CategoryNames];
$this->addChartData($this->encodeSpecialChars($data),"name=" . $this->encodeSpecialChars($label) . ";" .$strParam,"" );
}


}

}
Post #5542
« Prev Topic | Next Topic »


Permissions Expand / Collapse

All times are GMT -7:00, Time now is 7:06pm


Execution: 0.109.