PhpED: PHP IDE
new features
features
version comparison
features: php tools
php debugger
php profiler
php frameworks
php scripts
features tour
licensing
php testing
PhpED difference
PhpED on Mac/Linux
testimonials
PhpDock
Nu-Coder
PhpExpress
TechPlatform

PHP Database

PHP Database connection code is almost certain to be a part of any PHP application. NuSphere DB-Form Wizard replaces the pain of writing this code to a few button clicks in the intuitive User Interface and generates PHP code connecting to MySQL, MSSQL, Oracle, PostgreSQL, FireBird or SQLite database. PHP Database script generated by DB-Form Wizard can view, update, delete and insert new records into a selected table. PHP Database

How to generate PHP code working with Database

You can generate PHP code for the Database in just 3 minutes in PhpED. Db-Form Wizard uses templates and style configuration files to generate the Database form and gives you the full control over the look and feel of your applications and forms. For example, you can use PHP code implementing Ajax for Database connection requests and produce User Interfaces capable of sending asynchronous web browser requests to PHP scripts on the server. It also comes with pre-configured templates that produce the Form shown here: PHP Database Form

Please take look at the example of generating PHP MySQL code and keep it in mind that the same technique can be used for working with any other Database type.

How to make your own template for PHP Database code

PhpED Manual available under Help->PhpED Manual provides the information necessary for making your own PHP Database templates. Db-Form Wizard used Macro substitution mechanism for PHP code generation. The following table gives the overview of Db-Form Macros:
Macro Description Result of the substitution in the target file
@@CONFIG@@ Reference to configuration file, containing PHP Database connection settings
require_once "config.inc.php";
@@TABLENAME.
QUOTED@@
Name of the table selected in DB-Form Wizard, surrounded in single quotes For example
$table=@@TABLENAME.QUOTED@@;
will become:
$table='rates';
@@TABLENAME.
ALPHANUM@@
Name of the table selected in DB-Form Wizard, without quotes For example
ajaxRequest.open("GET",
"table_@@TABLENAME.
ALPHANUM@@.php")
will become
ajaxRequest.open
("GET","table_rates.php")
@@FIELDDEFS@@ Array representing the schema of the selected table. Each element of the array is a key=>value pair, where key is a unique identifier of each table field and the value is the array of field descriptors. See detailed field descriptions below this table. For example:
$fielddef = @@FIELDDEFS@@;
will become
$fielddef = array(
 'f0' => array(
  FLD_ID => true,
  FLD_VISIBLE => true,
  FLD_DISPLAY => 'PERSONID',
  FLD_DISPLAY_SZ => 7,
  FLD_INPUT => true,
  FLD_INPUT_TYPE => 'text',
  FLD_INPUT_SZ => 7,
  FLD_INPUT_MAXLEN => 10,
  FLD_INPUT_DFLT => '''
  FLD_INPUT_NOTEMPTY => true,
  FLD_INPUT_VALIDATION =>
'Numeric',
  FLD_DATABASE => 'PERSONID'
 ),
 'f1' => array(
  FLD_ID => false,
  FLD_VISIBLE => true,
  FLD_DISPLAY => 'FIRSTNM',
  FLD_DISPLAY_SZ => 100,
  FLD_INPUT => true,
  FLD_INPUT_TYPE => 'text',
  FLD_INPUT_SZ => 100,
  FLD_INPUT_MAXLEN => 32,
  FLD_INPUT_DFLT => ''
 )
);
@@EXTRAINIT@@ Associative array used for initialization of the form elements set to be of the select type by the user on Select Fields page For example, if the third field in the records set to be the select type control, the macro will be substituted with
$f2_values = array(
 '0' => 'Value1',
 '1' => 'Value2'
);


Field Descriptions generated by @@FIELDDEFS@@ macro
  • FLD_ID - true if the field is marked as Key in Select Fields page of DB-Form wizard, false otherwise
  • FLD_VISIBLE - always set to true, can be changed by editing the generated code only
  • FLD_DISPLAY - value of the Label field set by the user on Select Fields page of DB-Form wizard
  • FLD_DISPLAY_SZ - value of the Width field set by the user on Select Fields page of DB-Form Wizard
  • FLD_INPUT - always set to true, can be changed by editing the generated code only. If chaged to false in standard template, the corresponding field in generated Form will not be visible in Insert and Update forms
  • FLD_INPUT_TYPE - type of the HTML Form element used to display the field, as set by the user on Fields page of DB-Form wizard
  • FLD_INPUT_SZ - set to value of the Width field set by the user on Select Fields page of DB-Form wizard. Can be changed in the code if the different size of input is desired.
  • FLD_INPUT_MAXLEN - set to value of the MaxLen field set by the user on Select Fields page of DB-Form wizard.
  • FLD_INPUT_DFLT - always left empty, can be edited in generated code
  • FLD_INPUT_NOTEMPTY - true, if user checked Required checkbox for the corresponding field on Fields page of DB-Form wizard.
  • FLD_INPUT_VALIDATION - set to the validation type selected by the user on Select Fields page of DB-Form wizard.
  • FLD_DATABASE - field name in the database
Please see Ajax PHP Database Form for the example of the usage of the macros in custom templates.

In this tutorial you learned about features of DB-Form Wizard for PHP Database Code and how to use them to code PHP faster. Additional technical information is available from the NuSphere Forum. Download a free trial of our PHP IDE with PHP Database 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

Best PHP Editor and complete PHP IDE.
NuSphere PhpED 21.0 is available from our online store front.
"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

Walk through NuSphere PhpED interface
PhpED video tutorial: Webservices
Learn how to add webservices to your code in less than 5 minutes (a flash demo).

 Special Team4 Offer

Get 4 copies of PhpED for the price of 3!

Optimum solution for development teams.
PhpED 21.0 Team4
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

Dr. Dobb's Magazine covers NuSphere PhpED in New and Noteworthy section.

 InfoWorld

infoworld.com
PhpED is a proper, world-class IDE for PHP code. It is the only IDE worth considering if PHP development is your primary job