Hi, I have an Appgini app that is Is working quite nice and now I need to get some data out of the environment to work safe.
I need to make some “digging†into a DB, then to send that outcome of that to a txt or json to a txt file in the server that will be pulled with an another app.
Im more on the C# developing side and learning the APPGINI+/php/mysq ways and really enjoying it. Here is what I have in php
$sqlData = "SELECT * FROM Usuario INTO OUTFILE 'myoutput.txt'"; //ceate query
$resultData = $conn->query($sqlData); //créate the query execution
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); //create file
fwrite($myfile, $resultData); //write result of data gather
fclose($myfile); // close
this is not working. Any tip?
A3
Creating a file to be downloaded from server.
-
- Veteran Member
- Posts: 104
- Joined: 2018-12-10 21:52
-
- Veteran Member
- Posts: 104
- Joined: 2018-12-10 21:52
Re: Creating a file to be downloaded from server.
I do create a file via php, my issue is that i need to make a select and drop it lika a json...
anyone?
anyone?
Re: Creating a file to be downloaded from server.
Hi,
from what I can see
But if that is not what you want, you need to change that a little bit:
Try:
from what I can see
will create a file myoutput.txt with the data from Usuario$sqlData = "SELECT * FROM Usuario INTO OUTFILE 'myoutput.txt'"; //ceate query
$resultData = $conn->query($sqlData); //créate the query execution
But if that is not what you want, you need to change that a little bit:
Try:
Code: Select all
$sqlData = "SELECT * FROM Usuario'";
$res=sql($sqlData,$eo);
while ($row=db_fetch_assoc($res)) {
$mydata[]=$row;
}
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!"); //create file
fwrite($myfile, json_encode($mydata)); //write result of data gather
fclose($myfile); // close
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
- Veteran Member
- Posts: 104
- Joined: 2018-12-10 21:52
Re: Creating a file to be downloaded from server.
THANKS A LOT YOU SAVED ME tons of time
I coded a different solution but with a big caveat: TEXT FILE, anyhow I post the code here for anyone else who need to dump to text with a selected delimiter:
$resultData3 = $conn->query($sqlData3);
$delimitador = "\t";
while ($contador = $resultData3->fetch_assoc())
{
fwrite ($LogFile, join($delimitador, $contador) . "\n"); ----ïƒ Mi line
}
fclose($LogFile);
Your code helped me a lot since it throws the json file, it will be easier to handle in c#
I just added the JSON_PRETTY_PRINT to make it look cooler.
fwrite ($LogFile, json_encode($contador, JSON_PRETTY_PRINT)); //write result of data gather ----ïƒ Your much helpful code!
See you all!
A3
I coded a different solution but with a big caveat: TEXT FILE, anyhow I post the code here for anyone else who need to dump to text with a selected delimiter:
$resultData3 = $conn->query($sqlData3);
$delimitador = "\t";
while ($contador = $resultData3->fetch_assoc())
{
fwrite ($LogFile, join($delimitador, $contador) . "\n"); ----ïƒ Mi line
}
fclose($LogFile);
Your code helped me a lot since it throws the json file, it will be easier to handle in c#
I just added the JSON_PRETTY_PRINT to make it look cooler.
fwrite ($LogFile, json_encode($contador, JSON_PRETTY_PRINT)); //write result of data gather ----ïƒ Your much helpful code!
See you all!
A3