In this tutorial I’ll show you how to create Sohag Developer project to generate a web page (PHP – HTML – Bootstrap) to implement basic SQL DML operations (Insert Update Delete Query) into MariaDB (MySQL) database table or view and generating the PHP, BootStrap, HTML code and HTML Form automatically for the selected columns of the database table or view.
In this tutorial I’ll use MariaDB you can follow the same steps using any supported database, Sohag Developer at the moment of writing this articale supports PostgreSQL, MariaDB, MySQL and SQLite.
1- Lunch Sohag Developer .
2 Connect to the MariaDB (MySQL) database.
Click on the connect icon (Plug Icon) the very first icon in the toolbar
Or goto File menu and click on Connect menu Item.
A connection dialog appears
From database type list choose MariaDB (also you can choose MySQL, PostgreSQL or SQLite)
Add the database credentials (you can use host and port default values by leaving them empty) and then press the
Connect button to connect to the databse.
3 Browse database schemas.
After connecting to the database a database information pane appears at the left hand side of the Sohag Developer Application, You
can use this pane to browse database schemas, tables and views in a hierarchical form.
4 Create a new project.
Press the New Project icon the second icon in the toolbar or press File Menu -> New Project item the New Project appears showing the welcome page.
Press Next button to proceed to the next page.
5 Set project name and location.
Change project to PHP Application from the list (note that Qt/C++ is the default project type).
Fill in the project name in the Project name field.
If you want to add the project in specific location the use Chang Location button to browse you computer or leave the default location which is the Documents folder of the current user then press finish button to close Project Wizard.
6 Create a new class.
A new class wizard will be opened automatically
Press next to proceed the wizard welcome page.
7 Select the database table or view.
Check the table or view from the table at the button of the page. When checking table or view you will see its data (schema name, table or view name and the type if it's a basic table or view).
If you can't see the table or view, you can search for it by writing in the find table box, that will filter the table view names and reduce them in the table to see the tables or views that matches the search word only.
After selecting the required table or view press next to proceed to the next step.
8 Select the required database table or view columns.
Now you can see all the columns of the previously selected table or view.
Check the columns you want generate HTML Form Element for it and use in the
generated PHP - SQL DML code that will be generated by Sohag Developer .
Check the column name you want to use, Also you can set the label for the
generated HTML Form Element by changing it in the label column(by default Sohag
Developer will process the column name and generates the label depending on
Also you can change HTML Form Element Type by selecting the widget from Set Widget To combobox and select the columns you want to change and then press Set Widget button, But leave them all as the default HTML Form Element which is Text Element.
Note that Sohag Developer will generate two widgets for every column one for the label which is always a QLabel (Can't be changed) and the other is the data widget by default it is a Text Element but can be changed.
After checking the required columns press next to proceed.
9 Set the class name .
Note this page is used with Qt/C++, So we will leave the default vaalues.
Change the class name if you would like to change it or leave the default value.
Select the Base Class which can be QWidget or QDialog.
Then press Finish to create the project and close the wizard.
10 Project summary.
After closing the project wizard a new tab opens and you can see the summary for the Project .
11 Generate the PHP project files.
Now we will generate the PHP project files corresponding to our Sohag Developer Project.
From the toolbar press the down arrow next to the Generate button a menu will appear press on the simple menu item.
(Sohag Developer contains many templates that you can use to generate the Qt/C++ code and yet only one for PHP).
After pressing on the PHP-Web menu item the Qt project files will be generated.
12 Explore the project files.
Now we will browse the project files to see the generated files.
Go to the Project Menu and press Open Project Location this will open the default browser for your system and you can see all the project files.
The generated project files as you can see Sohag Developer will generate index.php, add.php file, delete.php file,
edit.php file, and view.php for every Entity (table or view ) in the Sohag Developer project.
12 Explorer the generated php files using gedit text editor.
This a one of the files generated files