PHP Generator for MySQL online Help
Prev | Return to chapter overview | Next |
Configuring datasources
PHP Generator for MySQL creates webpages aimed at interaction with MySQL tables, views, and queries throw the web. This chapter explains how to manage data sources your pages are based. Live Demos.
List of data sources
This list displays all data sources pages of your website are based on. The Status column indicates if a data source is OK or provides a brief description of the problem that must be solved before the data source can be involved into the project (a more detailed description is displayed in bottom part of the window). The Create top-level page column indicates whether a top level page for this data source should be created (this option usually turned OFF for queries and views to be used only as lookup data sources).
Adding tables and views
To add a table or a view as a page data source, open the Select object window with the corresponding button.
Adding queries
To add a query, type the query text in the Query editor or load it from an .sql file with More > Load query from file... Moreover you can use queries stored a single .qrp file (query repository). This feature may be extremely useful if you need to share a set of the same queries between several different projects. To save/load queries to/from a single file, use More > Save all queries as repository / Load query repository items from the More button menu accordingly.
Invalid queries
PHP Generator automatically validates data sources and displays names of invalid queries in red; in this case the reason of the problem is displayed in the Status column. Please follow these simple rules to get your query valid.
Key columns
PHP Generator automatically inspects all data objects for key columns that are required for single-record operations like view, edit, and delete. For tables you have to define primary key constraints at the database level, for views and queries it is necessary to define key columns at this step of the wizard. If key columns are not defined for a data source, it is marked with No key columns label and a confirmation is displayed on moving to the next step. If one of the primary key columns in your updatable query or a view is autoincrement, set the appropriate flag to allow correct locating the newly record added via inline or modal forms.
Please note that you must define key columns for all data sources involved into the project including lookup data sources; otherwise duplicate records can be displayed in the data grid.
Set SQL statements
This button allows you to provide Insert, Update, and Delete statements for views and queries. These statements can be omitted if you don't plan to support insert, update, and delete operations for the corresponding page. If a view is updatable at the database level, these statements can be omitted as well: in this case they will be generated automatically (as for tables).
Views vs Queries
What is preferable: create a view in the database or a query directly in PHP Generator? We would recommend you to use views always when possible as in this case all business logic is concentrated in a single place (database). The only suitable exception is the case when you for some reasons cannot modify the database schema.
Prev | Return to chapter overview | Next |