Recent

Author Topic: fpc app in web project  (Read 6039 times)

kapibara

  • Hero Member
  • *****
  • Posts: 610
fpc app in web project
« on: December 03, 2016, 10:59:50 am »
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?
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

bee

  • Sr. Member
  • ****
  • Posts: 393
Re: fpc app in web project
« Reply #1 on: December 03, 2016, 01:58:17 pm »
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?
-Bee-

A long time pascal lover.

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #2 on: December 04, 2016, 03:05:00 am »
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?
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

derek.john.evans

  • Guest
Re: fpc app in web project
« Reply #3 on: December 04, 2016, 03:19:20 am »
If you have already achieved data entry via PHP, I would stick with PHP.


kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #4 on: December 04, 2016, 03:42:36 am »
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?


If you have already achieved data entry via PHP, I would stick with PHP.
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

derek.john.evans

  • Guest
Re: fpc app in web project
« Reply #5 on: December 04, 2016, 03:48:54 am »
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.
« Last Edit: December 04, 2016, 03:52:29 am by Geepster »

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #6 on: December 04, 2016, 04:24:27 am »
Quote
1) 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?

Quote
2) 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?

Quote
3) Are you Pascal aware enough to write crash/leak proof code?

More or less..  O:-)

Quote
4) 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?

Quote
Personally, 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. ;)

Quote
You 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.

Quote
How 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.
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

derek.john.evans

  • Guest
Re: fpc app in web project
« Reply #7 on: December 04, 2016, 05:20:08 am »
Hard to give advice. I wouldn't want you heading off in a direction just because I would have  >:D

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

  • Sr. Member
  • ****
  • Posts: 393
Re: fpc app in web project
« Reply #8 on: December 04, 2016, 08:32:20 am »
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.
-Bee-

A long time pascal lover.

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #9 on: December 04, 2016, 08:50:14 am »
@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
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

derek.john.evans

  • Guest
Re: fpc app in web project
« Reply #10 on: December 04, 2016, 11:44:10 am »
I think I found the issue. Ive never tested under linux, so I had a look. I'll fix it by tommorrow

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #11 on: December 04, 2016, 07:23:16 pm »
Thanks, thats valuable information.

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.
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: fpc app in web project
« Reply #12 on: December 04, 2016, 07:29:09 pm »
Great, I'm looking forward to try this.

I think I found the issue. Ive never tested under linux, so I had a look. I'll fix it by tommorrow
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

 

TinyPortal © 2005-2018