PHP MySQL
|
If you program in PHP you are almost certain to use MySQL database on the back end of your PHP Application. PHP MySQL is one of the most popular combinations used in web applications and as such must be supported by any serious PHP IDE. PhpED takes the support for PHP MySQL and PHP Database in general to the whole new level with DB-Form Wizard features. In this tutorial you will learn how you can generate PHP code for Forms to insert or update records in MySQL database with PhpED's DB-Form Wizard. You can also browse and manipulate MySQL databases using PhpED's DB Connection client, described in another tutorial. Look at this screenshot of NuSphere DB-Form Wizard.
|
|
|
How to generate PHP MySQL code
PHP MySQL connection code can be generated PhpED's DB-Form Wizard. You will need to setup MySQL Database Account in PhpED's DB Connection client first and then use that account in DB-Form Wizard.
With DB-Form Wizard you can:
- Create PHP Code that inserts or updates records to MySQL database
- Create separate PHP conifg.inc file with database settings or generate stand alone PHP Script
- Setup and use different styles for generated HTML forms
- Preview PHP to MySQL code before saving it to the file
PhpED's DB-Form Wizard is an easy to use but very powerful and configurable tool, which makes building PHP MySQL applications as simple as three mouse button clicks.
How to use PhpED's DB-Form Wizard
- To launch DB-Form Wizard in the PhpED main window, press Shift+Ctrl+Alt+D, or choose Tools > DB-Form Wizard on the PhpED menu.
- Click NEXT at the introductory page of the wizard.
- On the Select Host Properties page, enter the information to connect to your database. You are prompted to select a database connection account that is already defined from the drop-down list. If you don't have current MySQL database account, click ACCOUNTS next to DB Account field to define it in DB Connection Client. The following illustration shows selection of existing MySQL account.
|
|
|
- Enter the login and password to access the selected database account. You can check off Save Password box to save the password, but this is not recommended for security reasons. When you are finished, click NEXT.
- On the Select Database and Table page, use the drop-down lists to choose the MySQL database you want to work with, and the table whose data the form will access. For example, on this illustration the database "shopcart" and the table "items" are selected
|
|
|
- The next Style page prompts you to select the style of your form available in the dbwizard.ini file (located in the plugins directory). You can select one of the existing styles. If you like, you can define additional styles and templates following the guidelines described in the PhpED Manual.
- The Select Fields page allows you to choose the fields you want the form to incorporate. By default, all fields are selected (included), and they include their default settings. The following is the description of some of the columns in Select Fields tab:
- Field - Field of the selected MySQL Table
- Label - The Label for this Field to be displayed on the PHP Mysql Form
- Control Type - HTML Control to be used for this field, e.g. Text, Text Area, Check Box etc.
- Required - If checked will require the user to enter input in this controller, empty field will cause an error dialog to popup
- Validation - type of the validation to be applied to the control. Installed Default Standard Style of DB-Form Wizard provides the choice of validating the input as EMail, Alpha, AlphaNum, Numeric, Float, Date or Time. You can add your own validation methods to your PHP MySQL form.
- Key - if checked will identify the field as the unique ID of the record. In this case the field will be used in the update/delete interfaces of the generated PHP MySQL script.
|
|
|
- Use Form Properties to tell the wizard to either create new config.inc.php file with MySQL configuration parameters, append new configuration to the existing config.inc.php or add the configuration directly to the script with out generating a separate config file. Select one of the options and click NEXT.
|
|
|
- When you are satisfied with your code, click NEXT. The wizard closes and the PHP code for your MySQL form appears in the PhpED editor area. If you choose to create the form as well as a configuration file, both files will be opened for viewing, and appear on the Files bar for selection. The illustrations below show PHP code generated for table items from MySQL database shopcart and generated config.inc.php file:
|
|
|
Next step is to save generated PHP for MySQL code. You can now run generated PHP code to display the form and select, insert, delete or update the records in MySQL table. For example, you can use PhpED's embedded PHP Viewer as it shown on this illustration:
|
|
|
How to debug PHP MySQL code
As with any other PHP code, you can use PHP Debugger and PHP Profiler available in PhpED to debug and tune up PHP code working with MySQL. Illustration below shows PHP code inserting records to MySQL items table in PhpED's debugger.
In this tutorial you learned about the many features of the PHP DB-Form Wizard and how to use them to quickly generate PHP code working with MySQL database. Additional technical information is available from the NuSphere Forum. Download a free trial of our PHP DB-Form Wizard today!
|
|
|
|
|
Download NuSphere PHP IDE
Download a free trial of the fast PHP EDitor and robust Integrated Development Environment for PHP.
|
Buy NuSphere PhpED® now
|
"To be honest its bloody awesome, I have looked at loads of PHP editors and this is THE only one that actual works straight out of the box!!! Brilliant, well done."
Andrew Breward, Director of Technology caboodal.com
|
Guide
|
Special Team4 Offer
Get 4 copies of PhpED for the price of 3!
Optimum solution for development teams.
|
|
Need more than 4 licenses? Contact Us for more quantity discounts, please use "Ordering/Payment issue" subject on the form.
|
|
Dr. Dobb's
Dr. Dobb's Magazine covers NuSphere PhpED in New and Noteworthy section.
|
InfoWorld
PhpED is a proper, world-class IDE for PHP code. It is the only IDE worth considering if PHP development is your primary job
|
|