PHP

Q:
I wold like to know if php can be used for web application because i tried an example and go the message that the scripting language must be java script.
So it seems that Php scripting is used for desktop development. can someone confirm this? I’m using lianja 3.0
A:
The client code for web and/or mobile apps needs to be JavaScript.
A2:
Have a look at this video I created a little while ago.

https://www.youtube.com/watch?v=_FhVyBtcWjM

It shows how you can call client side code. I was using Foxpro, but I believe you can do the same thing with php.
You can use the
standard sections to build the front end, then use you back end calls to php.

Also – have a look at virtual tables. I use SQL Server often as my backend and Lianja handles it very well.


Q:
I have no idea where to put lianja code vs where to put the PHP code, and what are the limit of these codes.
For example, I tried putting echo ‘hello world’ (simple PHP) and see how that would affect a section / gadget, but I don’t see hello world displayed anywhere in any section / gadget. So is there a limitation on the PHP codes I can write? How do they integrate into Lianja code base and the UI components?

A:
PHP is just fine and stick with it in delegates as you are comfortable with it. For example I am VFP developer and now javascript does not seems so strange to me.

For beginning I would suggest you make copy of apps folder. Then open some demo app written in PHP and insert your code somewhere, run to see what happened.
Where you can find demo in “your” language? This link might help (not so outdated):
http://www.lianja.com/community/show…ipting-languag

Lianja is datacentric. You want to make an application which will show your tables in some relation, so your end user will Create new records/rows, Read it, Update and Delete (CRUD).
Thinking that
abstract way: you drag tables (sections) and define relations visually. These are Standard sections which are responsible for all CRUD and are doing this automatically.

Second way is Custom section. Here you write more code in your language according object hierarchy (same for all languages). Lianja is live, connected to data. As you add code, your page get more and more stuff. Even you reenter, all is there forever. And all without any designer.

Third way is Canvas section. More dragging of visual elements we used to, but running it – you will see it is not responsive for various devices and resolutions. Not nice.

If you are here for desktop applications, all ways are yours, pick any or mix.
If you tend to nondesktop applications only, or all (desktop + nondesktop), than you need to separate client and server side.
For client side VFP guys need to use javascript in delegates/methods which web browsers understand. This is bad news for us. VFP is good for server side only.
We can use only Standard sections or javascript version of Custom section or javascript version of Canvas section for client side.

Back to demo. Open Lianja Demo (in group Demo Desktop Apps, “lianjademo”).
Click “Custom” in upper part of screen. In this menu click “PHP Custom Section” (5.option). What you are looking at is made by PHP code and this is Way #2.
Preferred way is #1 (Standard sections), but you are currently eager to see as much PHP code in action as you can, Right?

You see grey subtitle “This is a PHP custom section”? On the right is the group of 4 icons. Click first (keyboard).
Editor will open in ppage_section1.php You will see comments explaining steps how to make such a section from scratch.

I suggest you change code here (or comment existing code) to see what is going on. I am looking at PHP for the first time in my life. I will add a button in step 3

Code:
// Step 3: create a "Pageframe" class and add it to the "Section"
$mysection->addObject("ui_tabs", "Pageframe");
$mysection->addObject("ui_button", "Commandbutton");

Then I click in the upper row of screen to 5.icon (sheet of paper). Under grid I get looong button.
Back to code by clicking “keyboard” icon or 5th icon in first row (pencil)

Then I try to define button’s caption. Ups! $ui_button.text=”Click me” is wrong in PHP. Need “->”. Ups! need “;” at end.
Finally I got it.

Code:
$ui_button->text="Click me";

I would then try to remove left listbox by commenting the line with addobject and every mention of ui_listbox.
5th icon to see it – and there is no listbox. I even did not need to “Desktop App View” to see my changes.

Code:
//--------------------------------------------------------------------------
// Step 6: Add a "Listbox" to the "Container" and set some of its properties
//$ui_cont->addobject("ui_listbox", "myListbox");
//$ui_listbox->fixedwidth = 200; 
//
////--------------------------------------------------------------------------
//// Step 7: Invoke the "Additems" method with a comma separated list of items to add to the Listbox
//$ui_listbox->additems("All,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");

You see my point? Try change code in little steps. “Try PHP data access” (8th option from Custom menu).

After that make new app with PHP as language and on southwind database (Dashboard: Create an App).
Drag some table (customers) and and Shift+drag (orders). Click + in front customers and click on header of second section of orders. You get all orders of one customer.
Navigate through customers and see how it is all bound. This is preferred NOCODE way.



 

Categories PHP

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.