I am trying to generate a SQL based on some inputs . I have a predefined SQL(in which i do some replacements) which will consume these inputs to generate the required SQL using ODBC connection
I have stored the predefined SQL in a JS file for now .
Here is the code for the same :
function get_Result($query_passed){
//echo "inPHP";
$conn=odbc_connect(connectiondetails) or die(odbc_errormsg());
$resultset = odbc_exec($conn, $query_passed);
$rowValues = [];
while(odbc_fetch_array($resultset)){
$rowValue = odbc_result($resultset,1);
array_push($rowValues,$rowValue);
}
echo $rowValues[1].$rowValues[2]; // for debugging purpose
odbc_close($conn); // closing the connection
}
suppose the input is column1,column3 The required SQL which has to be generated is :
Select column1,sum(l1+week*column3)+ ........sum(l175+week*column3) from tempTable
my JS code looks like :
$.ajax({
url: "logic/GetResultSet.php",
type: "post",
data:"query_To_Fire="+finQuery+"&action=get_Result",
success: function(data){
$("#finaleQuery").append("<b>Generated Query:</b>"+data);}
while debugging the JS i am getting the output as
select column1,sum(l1+week*column3)+...+sum(l76+week*column3)+LCLT_F3)1)����ȏ���ȏ 11 and so on
The weird characters also include some text later which has various details like my ajax call parameters , my passwords etc .
there won't be a problem if my input is column1,column2 is cos , there won't be any summation on column2
this has been bugging me since long . Any idea for this behaviour .
Note : I am working with sublime text so no option of debuggin the actual PHP code .
I finally got the issue .
PHP has a default setting of "4096" bytes for handling of LONG Fields . As mentioned here
overriding the setting works for me : ini_set("odbc.defaultlrl", "10K");
php.ini
can be modified to support project specific settings :
odbc.defaultlrl=4096 //default in php.ini
useful note :
; Handling of LONG fields. Returns number of bytes to variables. 0 means
; passthru.
odbc.defaultlrl=0 //to get as many characters as the long text contains.