fpc app in web project lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- fpcoder · 2016-12-03 09:59 I'm creating a website that takes input from a user and stores in a SQL database using PHP. Afterwards the database needs to be queried, data compared and calculations done to produce a report for the user. Is it possible to write a pascal program to create this report? It would be easier for me since I dont know PHP so well. And probably more efficient too, but how to go about it? ---------------------------------------------------------------------- bee · 2016-12-03 12:58 You can do pretty much everything using Pascal. So, yes it's possible. For web application, FPC provides fpWeb or FCL Web. What kind of report do you need? HTML report? PDF report? ---------------------------------------------------------------------- fpcoder · 2016-12-04 02:05 So you suggest I write a CGI app to generate the report. Good, I had forgotten what that was. :-) It should be a simple HTML page that the user can view in a browser. So weblaz seems the way to go, but what do you think about Brook? ---------------------------------------------------------------------- derek.john.evans · 2016-12-04 02:19 If you have already achieved data entry via PHP, I would stick with PHP. ---------------------------------------------------------------------- fpcoder · 2016-12-04 02:42 Thats an option, of course. Although I know pascal much better than PHP. The analysis that takes place after user input must rock a lot of tables, calculate and compare. Second, I figured it would be slow with PHP and compiled pascal code would be nicer to the hardware. Maybe it's no practical difference? User input to table contents is already successful with PHP. Pascal or PHP, I can't decide. What are some arguments pro et contra? Quote from: Geepster on December 04, 2016, 03:19:20 amIf you have already achieved data entry via PHP, I would stick with PHP. ---------------------------------------------------------------------- derek.john.evans · 2016-12-04 02:48 1) Can you run native code CGI on your server? I dont think you have mentioned that... 2) Can you access you database from Pascal? Try that first to see if thats working 3) Are you Pascal aware enough to write crash/leak proof code? 4) Have you looked into some PHP based report libraries? Personally, I code in Pascal and convert to PHP using PAS2PHP, but, that might be more problems for you. You say you need todo a lot of calculations? Can they be done in SQL? Or, do you need to run a SQL script to grab a subset of your database to process? How many records are we talking? PHP is just a front end to MySQL etc. So, after you give MySQL a SQL script, thats it. Then you have a result set size. ie: How many records? You may need to explain your requirements before someone can give you fully educated advice. ---------------------------------------------------------------------- fpcoder · 2016-12-04 03:24 Quote1) Can you run native code CGI on your server? I dont think you have mentioned that... You mean if it is allowed? The server will be my own, at least in the beginning. But later I can just buy space at a server that allows it? Quote2) Can you access you database from Pascal? Try that first to see if thats working Using Lazarus and writing GUI apps, yes. But maybe thats not how you mean? Quote3) Are you Pascal aware enough to write crash/leak proof code? More or less..  Quote4) Have you looked into some PHP based report libraries? Actually no, I just started with PHP. Though I used C until I switched to Delphi when it came onto the scene. Lucky PHP is much like C. Can you recommend some PHP report libraries? QuotePersonally, I code in Pascal and convert to PHP using PAS2PHP, but, that might be more problems for you. Why would that be a problem? I'm sure I will try it out before this story ends. QuoteYou say you need to do a lot of calculations? Can they be done in SQL? Or, do you need to run a SQL script to grab a subset of your database to process? I need to grab a subset, calculate and then _maybe_ repeat similar processes many times depending on each result before the final report is produced. QuoteHow many records are we talking? That depends on the number of users in the class that current user belongs to. Say 100'000 recorded users in each class and 50 records each. But it might be possible to optimize this so not all user- records need to be queried. There could be "information-categories" that sums things up and then say 1000 categories with 20 records each. So at least 20'000 records are needed to create a report. ---------------------------------------------------------------------- derek.john.evans · 2016-12-04 04:20 Hard to give advice. I wouldn't want you heading off in a direction just because I would have  If you cant guaranty you can compile FreePascal on your target server without problems, then, I'd say thats an issue. Again, I'd use PAS2PHP because Im better at coding OOP stuff in Lazarus than PHP, and it converts it all for me. Im happy to write a quick startup package for you. ie: Connect to a database, and output a table. If thats something you would like to try. Other than that, there is PHP or C#. I prefer C# over PHP due to being type safe, but, then PHP is just so well supported by servers. O, and perl, but that just looks like gibberish to me. ---------------------------------------------------------------------- bee · 2016-12-04 07:32 I've been using FPC to write F/CGI web apps for years (since 2006) without any significant problems. The requirement is you need permission to deploy your own custom binary into your hosting account. If you can do that, I don't see any problems. FYI, you may want to try my webCRT unit here for simple web app creation with ease. Note: my personal VPS is down by now, so you can't try the online demo. Sorry. ---------------------------------------------------------------------- fpcoder · 2016-12-04 07:50 @Geepster Sounds interesting, I take you up on the startup package. Will be interesting to try. And to see how PHP performs. Pas2php is downloaded, and I opened "hello world" example in Lazarus. So the code should be compiled and executed and then a .php file is produced? It didn't work straightaway, some messages on compile: Quote/usr/bin/ld.bfd: cannot find -lphplibrary project.lpr(32,1) Error: Error while linking ---------------------------------------------------------------------- derek.john.evans · 2016-12-04 10:44 I think I found the issue. Ive never tested under linux, so I had a look. I'll fix it by tommorrow ---------------------------------------------------------------------- fpcoder · 2016-12-04 18:23 Thanks, thats valuable information. Quote from: bee on December 04, 2016, 08:32:20 amI've been using FPC to write F/CGI web apps for years (since 2006) without any significant problems. The requirement is you need permission to deploy your own custom binary into your hosting account. If you can do that, I don't see any problems. FYI, you may want to try my webCRT unit here for simple web app creation with ease. Note: my personal VPS is down by now, so you can't try the online demo. Sorry. ---------------------------------------------------------------------- fpcoder · 2016-12-04 18:29 Great, I'm looking forward to try this. Quote from: Geepster on December 04, 2016, 11:44:10 amI think I found the issue. Ive never tested under linux, so I had a look. I'll fix it by tommorrow