myphpgenerator.pdf

129
Copyright © 2002-2013 SQL Maestro Group User's guide PHP Generator for MySQL

Upload: pedro-escale

Post on 23-Nov-2015

38 views

Category:

Documents


3 download

TRANSCRIPT

  • Copyright 2002-2013 SQL Maestro Group

    User's guide

    PHP Generator for MySQL

  • PHP Generator for MySQL HelpI

    2013 SQL Maestro Group

    Table of ContentsForeword 0

    I Welcome to PHP Generator for MySQL 1................................................................................................................................... 21 System Requirements ................................................................................................................................... 32 Installation ................................................................................................................................... 43 How can I purchase PHP Generator for MySQL? ................................................................................................................................... 54 License Agreement ................................................................................................................................... 75 About SQL Maestro Group

    ................................................................................................................................... 106 What's new

    II Getting started 11................................................................................................................................... 121 How to connect to MySQL ................................................................................................................................... 162 Projects ................................................................................................................................... 173 Command line options ................................................................................................................................... 184 Report sending ................................................................................................................................... 195 Shortcut keys

    III Configuring datasources 20................................................................................................................................... 221 Tables and views ................................................................................................................................... 232 Custom SQL queries

    IV Customizing webpages 25................................................................................................................................... 261 Page Editor

    .......................................................................................................................................................... 26Columns ......................................................................................................................................................... 27Setting a lookup editor......................................................................................................................................................... 30View properties......................................................................................................................................................... 33Edit properties......................................................................................................................................................... 43Multi-level autocomplete editor......................................................................................................................................................... 49Inline Insert and Inline Edit......................................................................................................................................................... 50String templates......................................................................................................................................................... 51Uploading files to webserver.......................................................................................................................................................... 54Master-Detail Presentations .......................................................................................................................................................... 58Events .......................................................................................................................................................... 67Filter .......................................................................................................................................................... 68Page Properties .......................................................................................................................................................... 69Data Partitioning .......................................................................................................................................................... 71RSS

    ................................................................................................................................... 742 Project Options

    V Webpages appearance 76................................................................................................................................... 791 Color schemes ................................................................................................................................... 802 Header and Footer

  • IIContents

    II

    2013 SQL Maestro Group

    ................................................................................................................................... 813 Custom CSS

    ................................................................................................................................... 834 Using templates

    VI Security settings 85................................................................................................................................... 871 Hard-coded authorization ................................................................................................................................... 892 Table-based authorization ................................................................................................................................... 913 Database server authorization ................................................................................................................................... 924 Permission manager ................................................................................................................................... 955 Record-level security

    VII Interface language 96

    VIII Common generation options 98

    IX Options 100................................................................................................................................... 1011 Application

    .......................................................................................................................................................... 101Page

    .......................................................................................................................................................... 104Generation defaults

    .......................................................................................................................................................... 105Display formats

    .......................................................................................................................................................... 106Output ................................................................................................................................... 1082 Editors & Viewers

    .......................................................................................................................................................... 108General

    .......................................................................................................................................................... 109Display

    .......................................................................................................................................................... 110SQL highlight

    .......................................................................................................................................................... 111XML highlight

    .......................................................................................................................................................... 112PHP highlight

    .......................................................................................................................................................... 113Code Insight

    .......................................................................................................................................................... 114Code Folding ................................................................................................................................... 1163 Appearance

    .......................................................................................................................................................... 116Bars and menus

    .......................................................................................................................................................... 117Trees and lists

    .......................................................................................................................................................... 118Edit controls

    .......................................................................................................................................................... 119Check boxes

    .......................................................................................................................................................... 120Buttons

    .......................................................................................................................................................... 121Page controls

    .......................................................................................................................................................... 122Group boxes

    .......................................................................................................................................................... 123Splitters

    Index 125

  • PHP Generator for MySQL Help1

    2013 SQL Maestro Group

    1 Welcome to PHP Generator for MySQL

    PHP Generator for MySQL is a tool for creating database-driven web applicationsvisually. It allows you to generate high-quality PHP scripts for working with MySQL tables,views and queries through the web. You needn't have any programming background touse it.

    Key features:

    Support for updatable SQL queries

    Master-detail presentations

    Event-driven content management

    Client-side data validation

    Custom pagination (display partitioning)

    Data export to PDF, XML, CVS, Excel and Word

    Support for hard-coded, table-based, and database server user authentication

    Record-level security

    Flexible appearance customization

    Multi-language support

    23

    54

    58

    69

    85

    95

    76

    96

  • Welcome to PHP Generator for MySQL 2

    2013 SQL Maestro Group

    1.1 System RequirementsClient environment

    Pentium PC or higher;

    Windows NT4/2000/XP/Vista/Windows 7/Windows 8;

    256 MB RAM (512 MB recommended);

    15 MB of free hard disk space;

    SVGA-compatible video adapter;

    Internet Explorer 9 or better.

    Server environment

    MySQL from 3.23 to 6.0; Linux/Unix or Windows Web Server; PHP 5.

  • PHP Generator for MySQL Help3

    2013 SQL Maestro Group

    1.2 InstallationTo install PHP Generator for MySQL on your PC:

    download the PHP Generator for MySQL distribution package from the download page

    at our site;

    run setup.exe from the local folder and follow the instructions of the installation

    wizard;

    find the PHP Generator for MySQL shortcut in the corresponding program group of

    the Windows Start menu after the installation is completed.

  • Welcome to PHP Generator for MySQL 4

    2013 SQL Maestro Group

    1.3 How can I purchase PHP Generator for MySQL?Thank you for your interest in purchasing PHP Generator for MySQL Professional!

    You can select licensing options and register PHP Generator for MySQL at its on-lineorder page. It is possible to purchase on-line, by fax, mail, toll-free phone call, or placea purchase order. We send the software activation key by email within 24 hours aftercompletion of the order process. If you have not received the activation key within thisperiod, please contact our sales department.

    All our products and bundles are shipped with 12 months of free upgrades (minor andmajor ones) or with 36 months of free upgrades for a quite small additional fee. After thisperiod you may renew your license for the next 12(36) months with a 50% discount.

    PHP Generator for MySQL has a free 30-day trial. Upon purchasing the product youconfirm that you have tested it and you are completely satisfied with its current version.

    To obtain technical support, please visit the appropriate section on our website orcontact us by email to [email protected].

  • PHP Generator for MySQL Help5

    2013 SQL Maestro Group

    1.4 License AgreementNotice to users: carefully read the following legal agreement. The use of the softwareprovided with this agreement (the "SOFTWARE") constitutes your acceptance of theseterms. If you do not agree to the terms of this agreement, do not install and/or use thissoftware. The use of this software is conditioned upon the user's compliance with theterms of this agreement.

    License grant. SQL Maestro Group grants you a license to use one copy of theversion of this SOFTWARE on any single hardware product for as many licenses as youpurchase. "You" means a company, an entity or an individual. "Use" means storing,loading, installing, executing or displaying the SOFTWARE. You may not modify theSOFTWARE or disable any licensing or control features of the SOFTWARE except as anintended part of the SOFTWARE's programming features. This license is nottransferable to any other company, entity or individual. You may not publish anyregistration information (serial numbers, registration keys, etc.) or pass it to any othercompany, entity or individual.

    Ownership. The SOFTWARE is owned and copyrighted by SQL Maestro Group. Yourlicense confers no title or ownership of the SOFTWARE and should not be construed asa sale of any rights for the SOFTWARE.

    Copyright. The SOFTWARE is protected by the United States copyright law andinternational treaty provisions. You acknowledge that no title to the intellectualproperty in the SOFTWARE is transferred to you. You further acknowledge that titleand full ownership rights to the SOFTWARE will remain the exclusive property of SQLMaestro Group and you will not acquire any rights to the SOFTWARE except asexpressly set forth in this license. You agree that any copies of the SOFTWARE willcontain the same proprietary notices which appear on and in the SOFTWARE.

    License and distribution. An unregistered copy of the SOFTWARE ("UNREGISTEREDSOFTWARE") may be used for evaluation purposes. The UNREGISTERED SOFTWAREmay be freely copied and distributed to other users for their evaluation. If you offerthis UNREGISTERED SOFTWARE installation package for download, then you agree to:

    replace existing version of the UNREGISTERED SOFTWARE installation package with thenew package immediately after a new version of the SOFTWARE is released by SQLMaestro Group, or

    delete an obsolete version of the UNREGISTERED SOFTWARE installation packageimmediately upon written email notice by SQL Maestro Group.

    A registered copy of the SOFTWARE ("REGISTERED SOFTWARE") allows you to use theSOFTWARE only on a single computer and only by a single user at a time. If you wish touse the SOFTWARE for more than one user, you will need a separate license for eachindividual user. You are allowed to make one copy of the REGISTERED SOFTWARE forback-up purposes.

    Reverse engineering. You affirm that you will not attempt to reverse compile,modify, translate, or disassemble the SOFTWARE in whole or in part.

    Unauthorized use. You may not use, copy, rent, lease, sell, modify, decompile,disassemble, otherwise reverse engineer, or transfer the SOFTWARE except asprovided in this agreement. Any such unauthorized use shall result in immediate and

  • Welcome to PHP Generator for MySQL 6

    2013 SQL Maestro Group

    automatic termination of this license.

    No other warranties. SQL Maestro Group does not warrant that the SOFTWARE iserror-free. SQL Maestro Group disclaims all other warranties with respect to theSOFTWARE, either express or implied, including but not limited to implied warranties ofmerchantability, fitness for a particular purpose and noninfringement of third partyrights. Some jurisdictions do not allow the exclusion of implied warranties or limitationson how long an implied warranty may last, or the exclusion or limitation of incidental orconsequential damages, so the above given limitations or exclusions may not apply toyou. This warranty gives you specific legal rights and you may also have other rightswhich vary from jurisdiction to jurisdiction.

    Limited warranty. This SOFTWARE is provided on an "AS IS" basis. SQL MaestroGroup disclaims all warranties relating to this SOFTWARE, whether expressed orimplied, including but not limited to any implied warranties of merchantability or fitnessfor a particular purpose. Neither SQL Maestro Group nor anyone else who has beeninvolved in the creation, production, or delivery of this SOFTWARE shall be liable forany indirect, consequential, or incidental damages arising out of the use or inability touse such SOFTWARE, even if SQL Maestro Group has been advised of the possibility ofsuch damages or claims. The person using the SOFTWARE bears all risk as to thequality and performance of the SOFTWARE.

    Some jurisdictions do not allow limitation or exclusion of incidental or consequentialdamages, so the above given limitations or exclusion may not apply to you to the extentthat liability is by law incapable of exclusion or restriction.

    Severability. In the event of invalidity of any provision of this license, the partiesagree that such invalidity shall not affect the validity of the remaining portions of thislicense.

    No liability for consequential damages. In no event shall SQL Maestro Group or itssuppliers be liable to you for any consequential, special, incidental or indirect damagesof any kind arising out of the delivery, performance or use of the SOFTWARE, even ifSQL Maestro Group has been advised of the possibility of such damages. In no eventwill SQL Maestro Group's liability for any claim, whether in contract, tort or any othertheory of liability, exceed the license fee paid by you, if any.

    Entire agreement. This is the entire agreement between you and SQL Maestro Groupwhich supersedes any prior agreement or understanding, whether written or oral,relating to the subject matter of this license.

    Reserved rights. All rights not expressly granted here are reserved to SQL MaestroGroup.

  • PHP Generator for MySQL Help7

    2013 SQL Maestro Group

    1.5 About SQL Maestro GroupSQL Maestro Group is a privately-held company producing high-quality software fordatabase administrators and developers. The united team of eminently qualifieddevelopers is pleased to create new software products for commercial, academic andgovernment customers worldwide. We do our best to design and develop products thatremove complexity, improve productivity, compress time frames, and increase databaseperformance and availability. We are glad to realize that our products take usual choresupon themselves, so that our customers could have more time left for their creative work.

    The company was founded in 2002 as an essential partner for every business that istrying to harness the explosive growth in corporate data. SQL Maestro Group employs aninternational team concentrating their efforts on cutting-edge DBA tools development.

    The slogan of our company is The Shortest Path to SQL. It is aimed to denote that weset to create easy-to-use products meant for those who appreciate comfort, friendlyprogram interface and support when working with SQL servers.

    We are pleased to facilitate your job.

    We aim at being of considerable assistance to our clients.

    We feel contented doing our beloved work.

    At present, our company offers a series of Windows GUI admin tools for SQLmanagement, control and development of the following servers: MySQL, Microsoft SQLServer, PostgreSQL, Oracle, SQL Anywhere, DB2, SQLite, Firebird, and MaxDB. Wealso produce universal tools to be used for administering any database engine accessiblevia ODBC driver or OLE DB provider. Such products may be the clear-cut decision forthose who constantly work with several database servers.

    SQL Maestro is the premier Windows GUI admintool for database development, management, andcontrol.

    It provides you with the ability to perform all thenecessary database operations such as creating,editing, copying, extracting and dropping databaseobjects; moreover, you can build queries visually,execute queries and SQL scripts, view and editdata including BLOBs, represent data as diagrams,export and import data to/from most popular fileformats, manage users and their privileges (ifpossible), and use a lot of other tools designed formaking your work with your server comfortable andefficient.

  • Welcome to PHP Generator for MySQL 8

    2013 SQL Maestro Group

    SQL PHP Generator is a powerful tool for creatingdatabase-driven web applications visually. It allowsyou to generate high-quality PHP scripts forworking with tables, views and queries through theweb. You needn't have any programmingbackground to use it.

    SQL Data Wizard is a high-capacity Windows GUIutility for managing your data.

    It provides you with a number of easy-to-usewizards for performing the required datamanipulation easily and quickly.The tool allows youto convert any ADO-compatible database to theOracle database, export data from Oracle tablesand queries to most popular formats, import datainto the tables, and generate ASP.NET scripts forthe selected tables and queries.SQL Code Factory is a premier GUI tool aimed atthe SQL queries and scripts development.

    It allows you to manage SQL queries and scriptsusing such useful features as code folding, codecompletion and syntax highlighting, build queryvisually, execute several queries at a time, executescripts from files, view and edit result data withfiltering, sorting and grouping abilities, export datato as many as 14 file formats including Excel, RTFand HTML, import data from Excel, CSV, XML andtext files, view and edit BLOBs in various way, builddiagrams based on Oracle data, and much more.Service Center for MySQL is a multi-functionalWindows GUI utility for MySQL server maintenanceand data reservation.

    It allows you to create tasks for backing your datainto a script, restoring data from a script,analyzing, checking, repairing and optimizingdatabase tables. In addition to these functions,Service Center for MySQL provides you with apowerful task scheduler, an ability of usingscenarios and other useful features.

    The software products are constantly optimized for the latest server versions support.

    You can use the following contact information if necessary:

    Our web-site www.sqlmaestro.com

    Postal address: SQL Maestro Group

  • PHP Generator for MySQL Help9

    2013 SQL Maestro Group

    140 Broadway, Suite 706 New York City, New York 10005United States

    Thank you for your interest to our company!

  • Welcome to PHP Generator for MySQL 10

    2013 SQL Maestro Group

    1.6 What's newPlease find out the latest PHP Generator for MySQL news at http://www.sqlmaestro.com/products/mysql/phpgenerator/news/

  • PHP Generator for MySQL Help11

    2013 SQL Maestro Group

    2 Getting started

    To create a database-driven web application,

    Connect to the database you want to work through the web;

    Configure datasources to be available;

    Customize data grids represented on web pages to be created;

    Set other generation options such as webpages appearance and interface

    language ;

    Specify security settings to protect your data from an unauthorized access.

    PHP Generator for MySQL allows you to save and restore all the options set during asession. All the session parameters may be saved and loaded to/from a project file.Loaded settings may be edited if necessary. To run a wizard with a project, followMore... > Load Project on the first wizard step and enter the name of the project file,recently used projects are also available from this popup menu. Find out more aboutworking with Projects .

    12

    20

    25

    98 76

    96

    85

    16

  • Getting started 12

    2013 SQL Maestro Group

    2.1 How to connect to MySQLConnection propertiesSet the connection parameters for the database you want the PHP scripts to work with.

    Script connection propertiesSpecify here connection parameters for MySQL server relatively to the webserver. Forexample, if your webserver and MySQL server are installed on the same computer, set Hostas localhost.

    PHP Generator for MySQL allows you to connect to MySQL servers directly, via SecureSHell (SSH) tunnel or HTTP tunnel.

    Direct connection It is the most natural and the most preferable connection mode. Use it each time it ispossible. Most of hosting companies allow direct connections to databases. However inmost cases you have to go to your control panel and add your home/office computerIP address or domain name to Access List - list of IP addresses allowed accessing fromoutside.

    SSH tunnel connectionIf your MySQL server does not allow direct connections from your remoteworkstations, you can establish connection to an allowed intermediate SSH server andforward all MySQL commands through the Secure SHell (SSH) tunnel.

    More about SSH tunnel connection

    To establish connection to intermediate SSH server and forward all MySQLcommands through the secure tunnel, you need to:

    1. Check I can connect to the server directly or via SSH tunneling.

    2. Follow the Configure SSH options link to open the SSH Options window.

  • PHP Generator for MySQL Help13

    2013 SQL Maestro Group

    3.Check Connect through the Secure Shell (SSH) tunnel and complete thefollowing fields:

    Host nameSpecify the host name or IP of your site. Note, that MySQL host namealways should be set relatively to the SSH server. For example, if both ofMySQL and SSH servers are located on the same computer, you shouldspecify localhost as Host name instead of server's external host name or IPaddress.

    Port numberEnter the port number for the SSH server.

    4. Enter valid User name for the remote server and select the Authenticationmethod and set corresponding credentials.

    Password-basedSet the password corresponding to the specified user.

    Key-basedSpecify the path to the Private key file with the corresponding Passphrase tolog in to the remote server.

    Keyboard interactive Keyboard authentication is the advanced form of password authentication,aimed specifically at the human operator as a client. During keyboardauthentication zero or more prompts (questions) is presented to the user.The user should give the answer to each prompt (question). The number and

  • Getting started 14

    2013 SQL Maestro Group

    contents of the questions are virtually not limited, so certain types ofautomated logins are also possible.

    HTTP tunnel connectionHTTP tunneling is a technique used in conditions of restricted network connectivityincluding firewalled networks, networks behind proxy servers, and NATs. It is theslowest way and is recommended to use if the others are impossible.

    More about connection via HTTP tunnel

    To connect to a remote server using an HTTP tunnel, you need to:

    1.Upload the connection PHP script to your website. The script is named mysql_tunnel.php and can be found under the installation folder, usually C:\Program Files\SQLMaestro Group\PHP Generator for MySQL.

    2.Select the I have to use HTTP tunneling radio button.

    3.Enter the connection PHP script URL, e.g. www.yoursite.com/files/mysql_tunnel.php.You can test the connection before the profile is created. Just use Test script usingdefault browser to open connection script in your browser, enter all the requiredconnection parameters and use the Test connection button.

    4. In case using of a proxy server use Configure tunnelling options to open the HTTPtunnelling options window and specify your proxy server connection parameters andHTTP authentication.

    Note: You are actually connecting to your database through the PHP script on theserver, so in most cases the host/server name is "localhost" unless the target server isnot installed on the same server as the Web server.

  • PHP Generator for MySQL Help15

    2013 SQL Maestro Group

    Irrespectively of a connection mode you should specify common credentials as follows:

    HostThe host name of the MySQL server.

    Port numberThe TCP/IP port to use if server is not localhost.

    User nameThe username used to connect to MySQL.

    PasswordThe password for the user account on server.

  • Getting started 16

    2013 SQL Maestro Group

    2.2 ProjectsPHP Generator for MySQL allows you to save and restore all the options set during asession. You need not to specify all options each time you work with the applicationanew; instead you can load all settings from a project and change them if necessary.

    Projects are very useful when working with PHP Generator. If you will close theapplication without saving a project, all carefully adjusted settings will be lost. To setthe same options next time, you'll need to repeat the process step by step again whilewith a project all the session parameters can be restored in a few mouse clicks.

    To create a project, configure datasources and click More > Save Project at any nextstep (Ctrl+S) or More > Save Project as... (Ctrl+Shift+S). All the settings you havemade will be saved to a file.

    To restore previously saved settings from a project, click More > Load Project at thefirst wizard step. Recently used projects are available from the More > Recent Projectspopup menu.

  • PHP Generator for MySQL Help17

    2013 SQL Maestro Group

    2.3 Command line optionsPHP Generator for MySQL supports a number of command line options that make itpossible to fully automate PHP scripts creation. To generate the command lineautomatically, load the project to be used or specify the generation options manuallyand click More > Generate command line. The Command Line Builder allows you to savethe prepared line to clipboard or to a batch file.

    The PHP Generator for MySQL command line syntax is as follows:

    MyPHPGenerator[.exe] [] [-o|output ] [-g|generate] [-h|help]

    MyPHPGenerator[.exe] The PHP Generator for MySQL program file.

    The project with all the task's settings. A directory where file are generated to.-g|generate Generate without running the GUI application.-h|help Show help information.

    ExamplesThe examples below assume that you are entering the command lines in the PHPGenerator for MySQL program directory. Don't forget to enclose all paths and filenamescontaining spaces in quotes.

    myphpgenerator "C:\Templates\PHP_GENERATOR\MySQL\NBA_db.pgtm"

    fbphpgenerator "C:\Templates\PHP_GENERATOR\Firebird\online_store.pgtf" -g -o"C:\webserver\localhost"

    16

  • Getting started 18

    2013 SQL Maestro Group

    2.4 Report sendingTo send a report to SQL Maestro support team, use the corresponding PHP Generator forMySQL feature. To invoke the window, click More > Send report... .

    Check the corresponding options to include project file, schema, and specified number ofthe table records, add the problem description and click Send record to get the preparedreport in your default email client. In case you have no browser installed save theprepared report to a file with the corresponding option and send it manually [email protected] as email attachment.

  • PHP Generator for MySQL Help19

    2013 SQL Maestro Group

    2.5 Shortcut keysThe following table describes the default shortcut keys in PHP Generator for MySQL.

    Interface

    Load project Ctrl+OSave project Ctrl+SSave project as... Ctrl+Shift+SNext step Shift+NPrevious step Shift+BGenerate PHP scripts Shift+RExit Alt+F4PHP Generator for MySQL help Shift+H

  • Configuring datasources 20

    2013 SQL Maestro Group

    3 Configuring datasources

    PHP Generator for MySQL creates webpages aimed at interaction with MySQL tables,views, and queries throw the web, so the number of generated webpage is equal to thenumber of specified data objects.

    Adding tables and viewsTo add a table or a view, open the Select object window with the correspondingbutton.

    Adding queriesTo add a query, type the query text in the Query editor or load it from .sql file withMore > 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 ofthe same queries between several different projects. To save/load queries to/from asingle file, use More > Save all queries as repository / Load query repository items fromthe More button menu accordingly.

    Primary keysThe wizard automatically inspects all data objects for unique identifiers that arenecessary for add, edit, and delete operations. It marks objects without primary keyconstraints with No key columns label and asks a confirmation on moving to the nextstep. It's recommended to specify a single column or a set of columns that uniquelyidentifies each record in the view/query to expedite the work of the generatedapplication. It's optional but preferable.

    Invalid queriesThe wizard also automatically validates data objects. The Objects list displays thenames of invalid queries in red. Occasionally a valid SQL query that runs well is displayedby PHP Generator for MySQL as invalid. This happens because the tool validates thespecified query with a query like this:

    select * from(YOUR_SPECIFIED_QUERY_TEXT) tb_alias

    So SQL queries that contains the * sign or columns with the same names.

    22

    23

  • PHP Generator for MySQL Help21

    2013 SQL Maestro Group

    By default, each script has settings defined by the application options . Of course,you can change them later, but it's useful to setup the generation rules in accordancewith settings of the most webpages to reduce further adjustments.

    101

  • Configuring datasources 22

    2013 SQL Maestro Group

    3.1 Tables and viewsTo specify source database objects for working through the web, pick the objects in the Select objects tab. To choose several objects at a time, select them using Ctrl andShift keys, then click Mark selected.

  • PHP Generator for MySQL Help23

    2013 SQL Maestro Group

    3.2 Custom SQL queriesTo add a query within the editor, use the Create Query button or select thecorresponding popup menu item, then type the query name and text, and click OK.

    Creating updatable datasets (For Professional Edition Only)To get an updatable dataset based on an SQL query, you have to provide up to threeSQL queries: UPDATE, INSERT, and DELETE to be able to modify, add and removerecords accordingly. The first query provides an UPDATE statement for modifying existingrecords; the second query provides an INSERT statement to add a new record to thetables; and the third one provides a DELETE statement to remove the records. Each ofthese queries can contain several parameterized statements that use parameters like :field_name.

    ExampleAssume that we have the following SELECT statement:

    SELECT id,

  • Configuring datasources 24

    2013 SQL Maestro Group

    first_name, last_name

    FROM customerWHERE last_name LIKE 'A%'

    To create an updatable dataset based on this query, INSERT, UPDATE and DELETEstatements can be specified as follows:

    INSERT INTO customer

    VALUES (:id, :first_name, :last_name);

    UPDATE customer SET id = :id,

    first_name = :first_name, last_name = :last_name

    WHERE id = :OLD_id;

    DELETE FROM customer WHERE id = :id;

  • PHP Generator for MySQL Help25

    2013 SQL Maestro Group

    4 Customizing webpages

    PagesThis tab contains the list of webpages to be created. Each page is based on adatasource defined on previous steps and is created with default settings defined by the application options . Use the Edit button to edit settings of a concrete webpage withthe Page editor . To exclude a webpage from the navigation menu of generatedpages, uncheck the Include into menu option. Note, that the pages will be displayed atthe navigation menu on the generated pages in the same order as they are disposed inthe grid. To reorder the webpages, use the corresponding link of the popup menu. TheReset and Reset all buttons allow you to setup webpages properties according to thegeneration rules .

    DetailsThis tab contains detail presentations for the page selected at the Pages tab. Thedetail presentations are created according to the master-detail relationships (if Setupdetails by foreign key option is enabled). Use the Reset and Reset all buttons tosetup detail pages properties according to the project options .

    Project OptionsTo specify default setting to be applied to each generated page, follow the Setupproject options to configure default page settings link. This properties may be edited forthe concrete page within the Page Properties window.

    101

    26

    104

    54

    104

    74

    74

    68

  • Customizing webpages 26

    2013 SQL Maestro Group

    4.1 Page EditorColumnsUse this tab to setup columns to be included into the result pages (List, View, Edit,Insert, etc.), column captions, data representation on viewing and editing, lookupoptions and more.

    DetailsUse this tab to adjust the page detail presentations and setup detail pages properties.

    EventsSet here the fragments of PHP code to be executed before or after a record was added,edited, deleted, etc.

    FilterUse this tab to reduce the number of records available at the generated page.

    Use the Page Properties window to setup common page properties such as view/edit/delete/filter/export abilities, pagination options, page header, and more.

    The Data Partitioning wizard allows you to create a custom pagination i.e. split therecords on the generated page by a specified criteria.

    4.1.1 Columns

    For each datasource PHP Generator for MySQL creates a bunch of presentations: theList presentation (data grid), the View presentation (on a record viewing), the Editpresentation (on a record editing), etc. The Columns tab of Page Editor allows you toadjust the presentations' appearance.

    The General tab allows you to configure column properties for all the presentations. Theproperties for a concrete presentation can be specified at the corresponding tab.

    Include/exclude columns to/from a concrete presentation (List, View, Edit, etc.) usingcorresponding boxes. Use Include into all presentations / Exclude from all presentationscommand from the tab's popup menu to get the column listed/unlisted on all generatedpages.

    To restore default column options, use the Reset column link from the tab's popup menu.

    Specify the column caption and set a lookup editor for the column if necessary. Bydefault, PHP Generator for MySQL enables a lookup editor for columns linked by a foreignkey with a single column from another table (if Setup lookups by foreign key option isenabled).

    The View properties determine how the column is displayed on the List, View, Printand Export pages.

    The Edit properties define how the column is represented on the Edit and Insertpages.

    26

    54

    58

    67

    68

    69

    27

    104

    30

    33

  • PHP Generator for MySQL Help27

    2013 SQL Maestro Group

    The Inline Edit, Inline Insert properties determine whether the column will beavailable for inline adding/editing and how it will be represented.

    To reorder columns, use the grid's popup menu of a concrete presentation.

    4.1.1.1 Setting a lookup editor

    Lookup editors are used in case you want to select for a field a value that correspondsto a pre-defined value e.g. a record of another dataset. PHP Generator for MySQLprovides you with two types of lookup editors: Radio group or Combo box. Select Radiogroup as the column's Edit properties if the number of the column values is quite little.

    Setting a lookup editor bound to a data source (table, view, query)If you create a PHP script for taking orders, the 'Orders' table will generally have a fieldhosting a number indicating the customer who made the order. Working directly with thecustomer number is not the most natural way; most users will prefer to work withcustomer names. However, in the database the customers' names are stored in adifferent table to avoid duplicating the customer data for each order by the same

    49

  • Customizing webpages 28

    2013 SQL Maestro Group

    customer. To get around such a situation, you can enable a lookup editor:

    check the Use lookup box;

    select the foreign table/view/query as Data Source;

    specify the field with the same data as Link field;

    set the field with data to appear in the lookup editor as Display field;

    By default, PHP Generator for MySQL enables a combo box lookup editor for a columnlinked by a foreign key with a single column from another table (if Setup lookups byforeign key option is enabled).

    To create a lookup editor represented data of several columns, create a query with allthe necessary data concatenated into a single column and specify the query as DataSource. A complete example can be found below.

    ExampleSuppose we have three tables: 'employee' with a list of office employees, 'job' withemployees' job titles and salaries, and 'department' with a list of office departments.

    See definitions here

    CREATE TABLE employee ( EMP_NO integer NOT NULL PRIMARY KEY, FIRST_NAME varchar(15) NOT NULL, LAST_NAME varchar(20) NOT NULL, JOB_CODE integer NOT NULL, DEPT_NO integer NOT NULL)

    CREATE TABLE job ( JOB_CODE integer NOT NULL PRIMARY KEY, JOB_TITLE varchar(25) NOT NULL, SALARY real NOT NULL )

    CREATE TABLE department ( DEPT_NO integer NOT NULL PRIMARY KEY, DEPARTMENT varchar(20) NOT NULL, HEAD_DEPT integer, MNGR_NO integer, BUDGET real, LOCATION integer, PHONE_NO char(20))

    To enable a lookup editor for the 'HEAD_DEPT' field of the 'department' tablerepresenting first name, last name, and job title of the employee, follow the steps abovewith the following query text:

    SELECT

    104

  • PHP Generator for MySQL Help29

    2013 SQL Maestro Group

    e.EMP_NO as ID, CONCAT(e.FIRST_NAME, ' ', e.LAST_NAME, ', ', j.JOB_TITLE) as FULL_NAME

    FROM employee e, job jWHERE e.JOB_CODE = j.JOB_CODE

    Setting a lookup editor bound to a custom value list

  • Customizing webpages 30

    2013 SQL Maestro Group

    To create a lookup editor bound to a custom value list i.e. to a list of values that arenot stored in a database table and cannot be retrieved by a query, process as follows:

    Click the ellipsis button next to the "Edit properties";

    Enter the list of the allowed values in pairs

    an_allowed_value=value_to_be_represented separated by a comma (Example:

    1=One,2=Two).

    By default, PHP Generator for MySQL creates lookup editors described above for columns

    based on enumeration data types.

    4.1.1.2 View properties

    This options group allows you to define the way the column data to be represented onthe List, View, Print and Export pages.

  • PHP Generator for MySQL Help31

    2013 SQL Maestro Group

    Display propertiesSelect the type of data representation. By default, the format of the column's data isthe same as it is set at the Project options . To change the format of column data or/and set such additional options of the representation like text alignment, height andwidth of images, and others, use the corresponding dialog opened by the ellipsis buttonnext to the Display properties. Moreover, along with representation properties availablefor editing within this dialog you can define your own properties with the Customattributes option. The option allows you to specify the content of standard HTML styletag. For example, to set the background color of the column, enter style="background-color:yellow" as Custom attributes. To implement more difficult data representation,especially for conditional data formatting, it's recommended to use theOnExtendedCustomDrawRow event .

    Availablerepresentations

    Additional options Result

    Text It's possible to set such style attributesas text alignment, and font options (bold,italic). The Max length value is the maxnumber of signs to be visible on thegenerated webpage. You can also allowto replace CR+LF by , to use HTML

    105

    58

  • Customizing webpages 32

    2013 SQL Maestro Group

    and Word wrapping and specify severalformat options to be applied to thecolumn data depending of data type(Number, Percent, String, Currency).

    DateTime Select the type of date time format.

    Image If BLOB data will be represented asimages, specify the size of all the columnimages with Resize type and Height andWidth fields. Image hints are set withtemplates .

    Filedownload

    If BLOB data will be represented as filedownloads, set a Download file name anda Content type using templates . TheContent type value is optional. Tochange the download image, generatethe project and change the download.giffile in the images folder.

    Checkbox There are three display types of booleandata: check box controls, custom images,custom text values. Select the necessaryoption and specify the custominformation (TRUE/FALSE captions orimages).

    Externalfile,Externalimage

    To represent data in such a way, specifythe Source prefix and Source suffix.

    ExampleSuppose there is a 'product' column withsuch data:firebird_maestro, sqlite_maestro,

    There are image files with the followingpaths:D:\Images\firebird_maestro_62x62.jpgD:\Images\sqlite_maestro_62x62.jpg

    To represent these images at the'product' column on the generated page,Select External Image as View Propertiesand setSource prefix=D:\Images\Source suffix=_62x62.jpg

    50

    50

  • PHP Generator for MySQL Help33

    2013 SQL Maestro Group

    Display as hyperlinkTo represent the column's data as hyperlink, check the Display as hyperlink option andspecify the HREF Template . Target controls where the new document is displayedwhen a user follows the link.

    _blank opens the new document in a new window._parent is used in the situation where a frameset file is nested inside

    another frameset file. A link in one of the inner framesetdocuments which uses "_parent" will load the new document wherethe inner frameset file had been.

    _self puts the new document in the same window and frame as thecurrent document. "_self" works the same as if you had not usedTARGET at all.

    _top loads the linked document in the topmost frame... that is, the newpage fills the entire window.

    Use the Header hint field to specify the the column caption's hint. By default, it is acomment to the table/view column.

    Fixed column widthTo set a fixed width of the grid, check the Fixed width, specify the Width, and selectthe Units.

    Units Meaningem The 'font-size' of the relevant font.px (pixels) Relative to the viewing device.in (inches) 1 inch is equal to 2.54 centimeters.cm Centimetersmm Millimeterspt (points) The points used by CSS 2.1 are equal to 1/72nd of an inch.pc (picas) 1 pica is equal to 12 points.

    The Totals option allows you to enable a grid footer to display summaries (Sum,Average, Count, etc) for all or selected grid columns.

    4.1.1.3 Edit properties

    Use the Edit properties to define the way the column data to be represented on the Editand Insert pages and set additional options within the dialog opened by the ellipsisbutton next to the Edit properties.

    Use Style custom attributes to specify the appearance of inserting data. For example,to set the font color of the column, enter style="color: red;" as Custom attributes.

    The Read only fields cannot be modified. However, a user can tab to it, highlight it, andcopy the text from it. Check the Required box if the field is mandatory. Set also theDefault value for the column (for adding new record only). PHP Generator for MySQLsupports some environment valiables such as CURRENT_USER_ID, CURRENT_USER_NAME,UNIQUE_ID.

    Additional format-specific optionsAvaila

    Additionaloptions

    Editor appearance

    50

  • Customizing webpages 34

    2013 SQL Maestro Group

    bleeditors

    Text

    Set theSize ofthe textblock. The Maxlengthvalue isthe maxnumber ofsigns toenter.

    Combobox

    Enter thelist of theallowedvalues inpairsan_allowed_value=value_to_be_representedseparatedby acomma(Example:1=One,2=Two).

    Specifythe most-frequentlyusedvalues tobe alwaysdisplayedat the topof the list.To dothis, clickthe ellipsisbuttonnext tothe Mostfrequentlyusedvaluesand add

  • PHP Generator for MySQL Help35

    2013 SQL Maestro Group

    valueswithin thecorrespondingwindow.

    You canalsoenable alookupeditorbasedthatcontainsone ormore tablecolumns.For thispurpose,specifyItemcaptiontemplate

    .

    Radiogroup

    Enter thelist of theallowedvalues inthe sameway as forCombo boxeditor.

    Autocompleteeditor

    Use thiseditor typeas lookupeditor towork witha quantityof records.

    Multi-levelautocompleteeditor

    Thecontrol isbased oncascadingdrop-down listsand allowsusers toselect avalue froma long liststep-by-

    50

  • Customizing webpages 36

    2013 SQL Maestro Group

    step. Forexample,when weselect acountry intheCountrydrop-down list,it willpopulatethe Citydrop-down listaccordingto thecountryselected,and soon. Tofind outmoreinstructions usethecorresponding topic

    .

    Specifythe levelsin thedialogopened bythe ellipsisbutton.To set anew level,enter thelevelcaption,parentdatasource (atable thatcontainsdata tobedisplayedon thenext levelof the

    43

  • PHP Generator for MySQL Help37

    2013 SQL Maestro Group

    editor),and thename ofthecolumnthe datato bedisplayed.Key fieldof theparentdatasourceand childfield tofilter mustcontainthe samevalues.

    Checkbox

    The editoris set forbooleancolumns bydefault.

    Checkboxgroup

    Enter thelist of theallowedvalues inthe sameway as forCombo boxeditor.

    DateTime

    Check offthe Showtime boxtorepresentthe onlydate. Bydefault,theformat ofthecolumn'sdata isthe sameas it isset at the Projectoptions 105

  • Customizing webpages 38

    2013 SQL Maestro Group

    . Use theDateTimeformatfield tosetupformat ofthecurrentcolumn.

    Time

    Thiseditor isused bydefault forcolumnsthat storetime-of-dayvalues.

    Spinedit

    Thiseditortypeallows youto set theconstraints (Minvalue,Max value) on theentereddata.

    Maskedit

    Use theeditcontrol todefine anedit boxthat limitsthe userto aspecificformatandacceptsonly validcharacters. Forexample,you candefine anedit boxfortelephone

  • PHP Generator for MySQL Help39

    2013 SQL Maestro Group

    numberssetting999-999-9999 asthe maskof theeditor. Inthis casethecreateddataentry fieldacceptsonlynumericinput andif a userthen triesto enter aletter inthis editbox, theapplication will notaccept it.

    Textarea

    Define thesize ofarea visibletext partusing theColumncount andRow countfields.

    HtmlWysiwyg

    Use theeditor toprovidePHPscripts'users withthe abilityto directlymanipulatethe layoutof a HTMLdatastored inthecolumn,without

  • Customizing webpages 40

    2013 SQL Maestro Group

    having totype orremembernames oflayoutcommands.

    Password

    Displaysthe field asa maskedtextbox.

    Fileupload

    If BLOBdata willbe editedwith sucheditor,you canlimit thesize of anuploadingfile withthe Usefile sizelimitationoption andthe Maxfile sizefield. Tostorenames,types,and sizesofuploadedfiles,specifythe propercolumnsas Filenamefield, Filetype field,and Filesize fieldrespectively.

  • PHP Generator for MySQL Help41

    2013 SQL Maestro Group

    Imageupload

    If BLOBdata willbe editedas Imageuploads,you canlimit thesize of anuploadingfile,specifycolumnsto storenames,types,and sizesofuploadedfiles in thesame wayas for Fileupload.To limitthe sizeofuploadedimages,use theUse imagesizelimitationoptions,and setthenecessary Maxwidth and Maxheight.

    Uploadfiletofolder,

    Uploadimag

    To usethecolumn tostorepaths touploadedfiles,setup theFolder touploadand theFile nameusing

  • Customizing webpages 42

    2013 SQL Maestro Group

    etofolder

    templates. To

    use arandomnumber asfilename,check the Generaterandomfilenamebox.

    TheGeneratethumbnailoptionallows youto saveresizedcopies ofuploadedimages toaspecifiedcatalog.To do it,check thecorresponding box,specifythe Fieldname thethumbnailpath tobe savedto, setthe Folderto uploadand thename ofthecreatedfile (It'spossibleto usetemplates

    orrandomfilenames)andsubmit

    50

    50

  • PHP Generator for MySQL Help43

    2013 SQL Maestro Group

    the resizerules.

    4.1.1.4 Multi-level autocomplete editor

    The editor appearanceMulti-level autocomplete editor is based on cascading drop-down lists and allows usersto select a value from a long list step-by-step. The picture below shows how it works:first we select a country from the Country drop-down list, then we select a city fromthe list of cities related to the selected country and select an address from the list ofaddresses in this city (for the second example).

    The number of levels is not limited, so you can create any similar editor using the sametechnique as described below.

    Database schema requirementsTo create a two-level editor, you need to have three tables: the first table is actuallythe table that is the data source for the generated webpage (Address in the exampleabove). The column the multi-level editor is creating for must refer to the primary keycolumn of the second table. The second table is the parent table to the first table (inour case it is City), and the third table is the parent table to the second one (Country).The foreign key constraints are not required but highly recommended to enforce thereferential integrity at the database level.

    To create a three-level editor, you need to have four tables linked with each other asdescribed above, and so on.

    ExampleLet's consider how to implement a three-level editor. Suppose we have the followingtables:

  • Customizing webpages 44

    2013 SQL Maestro Group

    Our goal is to create a three-level editor like this:

    to allow users of the generated web app to select the customer address in the simplestway.

    1. Open the Page Editor for the page based on the Customer table, select theAddress_id column, and specify its lookup properties . If you have defined a foreignkey constraint for this column in the database and the Setup lookup by foreign keyoption is enabled, these properties will be set automatically.

    27

    104

  • PHP Generator for MySQL Help45

    2013 SQL Maestro Group

    2. Select Multi-level autocomplete editor as Edit properties for this column (see thepicture above), then press the ellipsis button. A dialog window will be opened.

  • Customizing webpages 46

    2013 SQL Maestro Group

    3. Now it's time to add the first level. Click Add level and enter values in the Add filterdialog window as follows:

  • PHP Generator for MySQL Help47

    2013 SQL Maestro Group

    Click OK to save the changes. The list of levels now looks as follows:

  • Customizing webpages 48

    2013 SQL Maestro Group

    4. Add the next level in the same way:

  • PHP Generator for MySQL Help49

    2013 SQL Maestro Group

    Click OK in the Edit properties window to save all the settings and return to the PageEditor.

    4.1.1.5 Inline Insert and Inline Edit

    The Inline Insert/Inline Edit features allow a user to add/edit the content of thegenerated page quickly without having to switch modes or screens. All work is done onthe same interface which helps the user maintain context.

    To enable the inline inserting/editing:

    Make sure that the Insert (Edit) ability option is set as Inline at the Page

    properties .

    Specify the columns to be available for inline inserting (editing) at the Inline

    Insert (Inline Edit) tab of the Page Editor .

    If necessary define the way the column data to be represented on inserting/

    editing. By default, it is represented as it is set at the Edit/Insert properties of

    the General tab.

    68

    26

    26

  • Customizing webpages 50

    2013 SQL Maestro Group

    4.1.1.6 String templates

    String templates are used by PHP Generator for MySQL on setting HREF templates, hints,etc. The strings may contain column names enclosed by %.

    Examples:1. Suppose a table 'team' stores various info about NBA teams. The table has 'caption'column with such data:

    maverics

  • PHP Generator for MySQL Help51

    2013 SQL Maestro Group

    cavaliers

    To create links to the team home pages:http://www.nba.com/maverics/http://www.nba.com/cavaliers/

    set the HREF templatehttp://www.nba.com/%caption%/

    2. Suppose there is a table 'employee' storing employee info. The table has 'first_name'and 'last_name' columns with such data:

    Forest GumpSara Connor

    To add such hints to their photos on the generated webpage:Forest Gump PhotoSara Connor Photo

    Specify the hint template:%first_name% %last_name% Photo

    4.1.1.7 Uploading files to webserver

    There are two ways to store files on a webserver:1. Store files directly in the database (in BLOB columns).2. Store files on a disk. Database stores the paths to the files in this case.

    Uploading files to be stored in a databaseTo allow the uploading of files and images to a BLOB column, select File Upload or ImageUpload at the column's Edit properties and Click the ellipsis button next to Edit propertiesand set the additional parameters of the uploading.

  • Customizing webpages 52

    2013 SQL Maestro Group

    To limit the size of uploading files, check the Use file size limitation option and specifythe Max file size.

    To store original names, types, and sizes of the uploaded files, specify the propercolumns as File name field, File type field, and File size field respectively. (Optional)

    For image uploads you can limit the dimensions of uploaded images. For this purpose,check the Use image size limitation options, and set the necessary Max width and Maxheight.

    ExampleTo allow uploading images which size is not greater than 200Kb, width is not greaterthan 600px and height is not greater than 400px and to save the original file names tothe file_name column, specify the Edit properties as follows:

  • PHP Generator for MySQL Help53

    2013 SQL Maestro Group

    Uploading files to be stored on a disk To allow the generated PHP script to upload files to your webserver and save their pathsin your database, select Upload file to folder or Upload image to folder at the column'sEdit properties and click the ellipsis button next to Edit properties and set the additionalparameters of the uploading.

    Specify the folder to upload and names for uploaded files: a random number or a newname composed of original file name, original file extension and the size of original file.Example:Suppose we have files:sqlite_maestro.exe (14563609 Bytes)mysql_maestro.exe (27241901 Bytes)

  • Customizing webpages 54

    2013 SQL Maestro Group

    To upload them using the generated PHP script to the data/files/ folder as sqlite_maestro (14563609).exemysql_maestro (27241901).exe

    Specify the Edit properties as follows:

    4.1.2 Master-Detail Presentations

    Master-detail presentations allow you to navigate a webpage based on a specific table,and at the same time for each selected record (master record) see the associatedrecords from other related tables (details). So, browsing the page representing productinformation, you can see all the orders corresponding to the necessary products;working with list of countries - to inspect cities of specific countries as on the picturebelow.

    You can also create nested master-detail presentations when you can see the "detailsof details". On the picture below the webpage with a list of countries is represented, forany country all the corresponding cities may be browsed with one click and at the sametime it's possible to see all addresses of customers living in specific cities.

  • PHP Generator for MySQL Help55

    2013 SQL Maestro Group

    To add a master-detail relation within PHP Generator for MySQL means to provide eachrecord of the result webpage with an ability to browse all records associated with thisrecord on a separate Details page as well as with an ability to view the 20 first suchrecords on the result page directly. To open the corresponding Details page, follow thefull view link.

    Database schema requirementsTo create a two-level master-detail presentation, you need to have two tables with aparent-child relationship. The foreign key constraints are not required but highlyrecommended to enforce the referential integrity at the database level.

    RealizationThere are two ways to provide the result webpage with a master-detail presentation:

    The tables are tables linked with a foreign key. In case the Setup details by foreignkey option is enabled, the detail relation will be set automatically. 104

  • Customizing webpages 56

    2013 SQL Maestro Group

    The foreign key constraint between theses tables haven't been defined. 1. Open the Page Editor for the page based on the master table and go to the Details

    tab.

    2. Click the Add... item of the tab's popup menu.

  • PHP Generator for MySQL Help57

    2013 SQL Maestro Group

    3. Set the relation properties to the child table: select this table as Detail data source,and specify the columns with similar data as Master field (select from the list of parenttable columns) and Detail field (select from the list of child table columns).

  • Customizing webpages 58

    2013 SQL Maestro Group

    4. After the fields are completed use the Add button and then click OK.

    To specify the details appearance, use the Edit... item of the corresponding popup menuand set options in a usual way .

    To create a nested master-detail presentation, use the same technique as describedabove (the case the foreign key constraint is not defined).

    4.1.3 Events

    Event is a fragment of PHP/Javascript code executed before or after a record wasadded, edited, or deleted, etc. Therefore events allow you to define some actions thatwill be activated when certain conditions are met. All events are grouped into 2categories: Client side events and Server side events. Client side events are written onJavascript and executed by browsers while Server side events are written on PHP andexecuted by webserver.

    Working with eventsTo add/edit an event handler, select the necessary event in the list and double-click the Code column or use Ctrl+Enter. Then type PHP code in the Event Editor window.

    To temporarily disable/enable an event, select the appropriate line in the list anduncheck/check the corresponding Enabled box.

    Using variablesPHP Generator for MySQL supports some environment variables (such asCURRENT_USER_ID, CURRENT_USER_NAME, UNIQUE_ID) in events. To obtain a complete

    26

  • PHP Generator for MySQL Help59

    2013 SQL Maestro Group

    list of supported variables, uncomment the define('SHOW_VARIABLES', 1); line in thegenerated settings.php file and open any generated web page. The following exampledemonstrates how to use variables within the OnBeforeInsertRecord event.

    Example:$rowData['ip_address'] = $this->GetEnvVar('REMOTE_ADDR');$userName = $this->GetEnvVar('CURRENT_USER_NAME');if ($userName != 'admin') $rowData['changed_by'] = $userName;

    PHP Generator for MySQL supports the following events:

    Client side events:

    OnBeforePageLoad

    Occurs before page loading. Allows you to declare functions andglobal variables.

    OnAfterPageLoad

    Occurs after page has been fully rendered. This event does not gettriggered until all assets such as images have been completelyreceived and DOM hierarchy has been fully constructed.

    OnInsertFormValidate

    Occurs before submitting the insert form. This allows errors to be detected on theclient before the form is submitted, thus avoiding the round trip of informationnecessary for server-side validation.

    Parameters:$fieldValues- associative array of values contains user input.$errorInfo - object that provides interface (the SetMessage method) to set avalidation error message.

    Example:if (fieldValues['percents'] < 0 || fieldValues['percents'] > 100){ errorInfo.SetMessage('Percent value should be between 0 and 100.'); return false;}

    OnEditFormValidate

    Occurs before submitting the edit form. This allows errors to be detectedon the client before the form is submitted, thus avoiding the round trip ofinformation necessary for server-side validation.

    Parameters:$fieldValues- associative array of values contains user input.$errorInfo - object that provides interface (the SetMessage method) to

  • Customizing webpages 60

    2013 SQL Maestro Group

    set a validation error message.

    Example:if (fieldValues['percents'] < 0 || fieldValues['percents'] > 100){ errorInfo.SetMessage('Percent value should be between 0 and 100.'); return false;}

    OnInsertFormEditorValueChanged

    Occurs on changing a value in the Insert form.

    Parameters:$sender - a control whose value has been changed$editors - associative array of form controls

    Example:if (sender.getFieldName() == 'country_id'){ editors['college_id'].enabled(sender.getValue() == 1); if (sender.getValue() != 1) editors['college_id'].setValue(null); }

    OnEditFormEditorValueChanged

    Occurs on changing a value in the Edit form.

    Parameters:$sender - a control whose value has been changed$editors - associative array of form controls

    Example:if (sender.getFieldName() == 'current_team_id'){ if (sender.getValue() == '') { editors['current_number'].setValue(''); editors['current_number'].enabled(false); } else { editors['current_number'].enabled(true); }}

    OnInsertFormLoaded

    Occurs after the Insert form is loaded.

    Parameters:$editors - associative array of form controls

  • PHP Generator for MySQL Help61

    2013 SQL Maestro Group

    OnEditFormLoaded

    Occurs after the Edit form is loaded.

    Parameters:$editors - associative array of form controls

    Server side events:

    OnBeforePageExecute

    PHP code to be included at the begin of created PHP file. The code isexecuted only once and intended to create global objects, declarefunctions, and include third-party libraries.

    Example:Suppose we decided to implement a syntax highlighting using theGeSHi library somewhere in the generated application. To implementsuch a feature, we need (among other things) to include the mainlibrary file into the generated scripts:

    include_once '../geshi/geshi.php';

    OnCustomRenderColumn

    Occurs before column rendering. Allows to replace cell content. It isan extremely useful event for conditional rendering or embeddingthird-party components to extend standard functionality.

    Parameters:$fieldName - field name of currently processed cell.$fieldData - data of currently processed cell.$rowData - associative array of values that corresponds to thecurrently processed row.$customText - a string to replace original cell content.

    Example:Suppose a table 'employee' has a column storing dataabout the employee's sex in that way that '1'corresponds to male and '2' to female. Our goal is torepresent the employees sex as 'M' and 'F' for men andwomen accordingly. To do so, you could specify theOnCustomRenderColumn event handler as follows: if ($fieldName == 'sex') { $customText = $rowData['sex'] == 1 ? 'M' : 'F'; $handled = true;}

  • Customizing webpages 62

    2013 SQL Maestro Group

    OnCustomRenderPrintColumn

    Occurs before column rendering on print page. Allow to replace cellcontent. It is an extremely useful for conditional rendering orembedding third-party components to extend standard functionality.

    Parameters:$fieldName - field name of currently processed cell.$fieldData - data of currently processed cell.$rowData - associative array of valued that corresponds to thecurrently processed row.$rowData - a string to replace original cell content.

    OnCustomRenderExportColumn

    Occurs before column rendering into Word, Excel, etc. Allow toreplace cell content. It is an extremely useful event for conditionalrendering.

    Parameters:$exportType - a string contains exporting format short name (word,excel, pdf, csv, xml).$fieldName - field name of currently processed cell.$fieldData - data of currently processed cell.$rowData - associative array of valued that corresponds to thecurrently processed row.$rowData - a string to replace original cell content.

    OnCustomHTMLHeader

    Occurs when generating the head section of the page. Use this event to provideadditional information for the HEAD section of the page (such as keywords,author, or description).

    Parameters:$page - the page raised the event.$customHtmlHeaderText - a string to place into the head section.

    Example:$customHtmlHeaderText = '';

    OnExtendedCustomDrawRow

    Occurs when rendering a grid row (advanced features). It is an extremelyuseful event for conditional formatting such as changing font color, fontstyles, row background color, cell background color, etc.

    Parameters:$rowData - associative array of values that corresponds to the currentlyprocessed row.$cellStyles - associative array of styles. Each field name is associated with

  • PHP Generator for MySQL Help63

    2013 SQL Maestro Group

    its style string.$rowStyles - use this string to modify styles of a whole row.

    This event (as well as OnCustomDrawRow) is used for conditionalformatting. The only difference between these two events is thatOnCustomDrawRow has a more understandable parameter list whileOnExtendedCustomDrawRow provides more flexible abilities.

    Example:Please find below an example of the conditional row formatting from ouronline demo. We need to display winning team score in red and losing teamscore in black; moreover, both scores should be in bold and displayed by a16pt font.

    $rowCellStyles['home_team_score'] = 'font-size: 16pt;font-weight: bold;';$rowCellStyles['away_team_score'] = 'font-size: 16pt;font-weight: bold;';if ($rowData['home_team_score'] > $rowData['away_team_score']) $rowCellStyles['home_team_score'] .= 'color: #F65317;';else $rowCellStyles['away_team_score'] .= 'color: #000000;';

    OnCustomRenderTotals

    Occurs before total values rendering. Allows to replace default totalfooter content. Enabling this event don't forget to enable the gridfooter in the View properties of the corresponding column. Parameters:$totalValue - total value of currently processed total.$aggregate - string representation of total aggregate ('AVG', 'SUM','MIN', 'MAX', 'COUNT').$columnName - column name of currently processed total.&$customText - a string to replace total cell content.&$handled - indicates whether the event handler executed. Set$handled to true in the event handler to apply new content.

    Example:Suppose we need to change the text of the 'TOTAL_VALUE' columngrid footer.

    Set if ($columnName == 'TOTAL_VALUE'){ $customText = 'Total value average: ' . $totalValue . '$'; $handled = true;}Now we can compare the result webpages without using the eventand with the enabled one:

    30

  • Customizing webpages 64

    2013 SQL Maestro Group

    OnGetCustomTemplate

    This event handler occurs on opening a custom template and allows to use a customtemplate instead of the default one. The basic principles of custom template usage areshown in this article.

    In PHP Generator creates a set of templates written on Smarty 2.0 to be used by theprepared application in the certain situations. To change a webpage look in suchapplication, you need to specify a new template to be used and set it in this event. Thetemplate file should be uploaded to the 'components/templates/custom_template'directory. Parameters:$part - the part of the page to be affected by the template. Possible values are: PagePart::Grid allows to change the appearance of table grid.PagePart::GridRow allows to set the one row look.PagePart::VerticalGrid allows to apply the template to data grid placed at edit form, viewform and insert form.PagePart::PageList allows you to change the appearance of Navigation bar at thewebpage.PagePart::Layout - allows to completely redesign the webpage look.PagePart::RecordCard - data represented at the modal dialog

    $mode - the current state of the webpage the template to be used. Possible values are: PageMode::ViewAll allows to change the look of webpage representing table data.PageMode::View allows to specify a custom template.PageMode::Edit allows to modify the edit form of the table.PageMode::Insert allows to modify the insert form.PageMode::ModalView, PageMode::ModalEdit, PageMode::ModalInsert allow to change theappearance of data on viewing, editing and inserting in a modal dialog.

    $result - the path to the file to be used as template according to the components/templates/custom_templates folder.

    Example:Suppose we need to use components/templates/custom_templates/staff_edit.tpl file asa template for the edit form data.

    if ($part == PagePart::VerticalGrid && $mode == PageMode::Edit) { $result = 'staff_edit.tpl';}

    Now we can compare the result webpages without using the event and with the enabledone:

  • PHP Generator for MySQL Help65

    2013 SQL Maestro Group

    OnCustomDrawRow

    Occurs when rendering a grid row (basic features). It is an extremelyuseful event for conditional formatting such as changing font color,font styles, row background color, cell background color, etc.

    Parameters:$rowData - associative array of values that corresponds to thecurrently processed row.$cellFontColor, $cellFontSize, $cellBgColor, $cellItalicAttr,$cellBoldAttr - associative arrays of cell attributes.

    This event (as well as OnExtendedCustomDrawRow) is used forconditional formatting. The only difference between these two eventsis that OnCustomDrawRow has a more understandable parameter listwhile OnExtendedCustomDrawRow provides more flexible abilities.

    Example:Please find below an example of the conditional row formatting from

  • Customizing webpages 66

    2013 SQL Maestro Group

    our online demo. We need to display winning team score in red andlosing team score in black; moreover, both scores should be in boldand displayed by a 16pt font.

    $cellFontSize['home_team_score'] = '16pt';$cellBoldAttr['home_team_score'] = true;

    $cellFontSize['away_team_score'] = '16pt';$cellBoldAttr['away_team_score'] = true;

    if ($rowData['home_team_score'] > $rowData['away_team_score']) $cellFontColor['home_team_score'] = '#F65317';else $cellFontColor['away_team_score'] = '#000000';

    OnBeforeUpdateRecord

    Occurs when the Update command is executed, but before the actualupdate. This event is often used to cancel the update operation.

    Parameters:$rowData - associative array of values that corresponds to thecurrently processed row.$cancel - value indicating whether the operation should be canceled.$message - message string that is displayed after the operation iscompleted (or canceled)

    Example:$cancel = true;$message = 'Updating is disabled.';

    OnBeforeDeleteRecord

    Occurs when the Delete command is executed, but before the actualdeletion. This event is often used to cancel the delete operation.

    Parameters:$rowData - associative array of values that corresponds to thecurrently processed row.$cancel - value indicating whether the operation should be canceled.$message - message string that is displayed after the operation iscompleted (or canceled)

    Example:$cancel = true;$message = 'Deleting is disabled.';

    OnBeforeInsertRecord

    Occurs when the Insert command is executed, but before the actualinsertion. This event is often used to cancel the insert operation.

  • PHP Generator for MySQL Help67

    2013 SQL Maestro Group

    Parameters:$rowData - associative array of values that corresponds to thecurrently processed row.$cancel - value indicating whether the operation should be canceled.$message - message string that is displayed after the operation iscompleted (or canceled)

    Example:$cancel = true;$message = 'Inserting is disabled.';

    Events specified as project options will be used for all generated web pages.

    4.1.4 Filter

    To reduce the number of records available at the page, specify the Filter condition. Thiscondition corresponds to the WHERE clause of the query returned page data (you mustnot add the WHERE keyword to beginning of the condition).

    Example 1There is a table with test questions of a Web programming course. To display onlyquestions of the 'Beginner' level (level_id = 2) concerning to PHP(statement_language_id = 1), set the filter condition as follows:

    Example 2You can use subqueries in the filter expression. For example, to display the list ofchannels that hosted even if a single game, specify the Filter condition as follows:

    (channel.id > 0) AND channel.id IN ( SELECT game.channel_id FROM game)

  • Customizing webpages 68

    2013 SQL Maestro Group

    4.1.5 Page Properties

    The Page Properties window allows you to define the general properties of the generatedpage. To invoke the window, use the corresponding button of Page Editor .

    CommonSpecify here the basic HTML elements such as Caption of the generated HTML page, Filename (if the file name extension is not specified, it will be the same as at the application output options ). Short Caption is a text of the link representing the page at Navbar.To add a text to be displayed at the top of the page, use the Page Header field or openthe Page Header window with the ellipsis button (for details see the screenshot below).

    Default sort orderTo set the default sort order of the generated page data, check the Default orderingbox, specify the name of the column the data to be sorted according with and selectthe sort order.

    Fixed width of the gridTo set a fixed width of the grid, check the Grid fixed width, specify the Width, andselect the Units.

    Units Meaningem The 'font-size' of the relevant font.px (pixels) Relative to the viewing device.in (inches) 1 inch is equal to 2.54 centimeters.cm Centimetersmm Millimeterspt (points) The points used by CSS 2.1 are equal to 1/72nd of an inch.pc (picas) 1 pica is equal to 12 points.

    Creating RSS feedsThe Use RSS options group allows you to create an RSS feed based on the currenttable.

    Opening search page at first

    26

    106

    71

  • PHP Generator for MySQL Help69

    2013 SQL Maestro Group

    For tables storing a lot of data it's reasonable to allow users to work only with anecessary piece of data. For this purpose, check the Open search page at first box andthe generated page will be opened with a search page.

    The other properties are set in accordance with the project options . To change theproperties, check off the Use default options box and enter the new value in thecorresponding field.

    4.1.6 Data Partitioning

    The Data Partitioning wizard allows you to create a custom pagination i.e. split therecords on the generated page by a specified criteria.

    Select the type of data partitioning on the first wizard step:

    Range partitioning

    Selects a partition by determining if the partitioning expression value is inside a

    certain range.

    List partitioning

    A partition is assigned a list of values. If the partitioning expression value has one

    of these values, the partition is chosen. For example, all rows where the column

    'Country' is either Iceland, Norway, Sweden, Finland or Denmark could build a

    partition for the 'Nordic countries'.

    Custom partitioning

    Create your own partitioning with fill partitions and build conditions functions.

    To disable data partitioning, select None.

    Example 1 (Range partitioning)There is a table storing information about films such as title, release year, and length.See definition here

    CREATE TABLE film ( film_id integer NOT NULL, title varchar(255) NOT NULL, release_year integer, length integer UNSIGNED, /* Keys */ PRIMARY KEY (film_id));

    To create a pagination by the film length, select Range partitioning at the first wizardstep, choose 'length' as partition expression and set the partitioning ranges as follows:

    101

  • Customizing webpages 70

    2013 SQL Maestro Group

    Here you can see the result PHP script:

    Example 2 (Custom partitioning)Assume that a table 'customer' contains the 'last_name' column. Our goal is to groupcustomers by the first letter of their last name as displayed below.

  • PHP Generator for MySQL Help71

    2013 SQL Maestro Group

    To get around such a situation, select Custom partitioning and define functions asfollows:

    function GetPartitions($partitions){ $tmp = array(); $this->GetConnection()->ExecQueryToArray(" SELECT DISTINCT left(c.last_name, 1) as first_letter FROM customer c ORDER BY first_letter", $tmp ); foreach($tmp as $letter) { $partitions[$letter['first_letter']] = $letter['first_letter']; }} function GetPartitionCondition($partitionKey, &$condition){ $condition = "left(last_name, 1) = '$partitionKey'";}

    4.1.7 RSS

    With PHP Generator for MySQL you can create full-fledged RSS feeds based on MySQLtables. To create an RSS document, open the Page Properties dialog and complete the

  • Customizing webpages 72

    2013 SQL Maestro Group

    Use RSS options group.

    Check the Use RSS box first and specify the following options:

    Channel titleDefines the title of the channel.

    Channel linkDefines the hyperlink to the channel.

    Channel descriptionDescribes the channel.

    Item title templateDefines the title of the item.

    Item link templateDefines the hyperlink to the item.

    Item description templateDescribes the item.

    Item publication date fieldThis field is optional. Defines the last publication date for the content of the feed.

    For more details see the RSS specification.

    The screen below provides you with a simple example.

    50

    50

    50

  • PHP Generator for MySQL Help73

    2013 SQL Maestro Group

  • Customizing webpages 74

    2013 SQL Maestro Group

    4.2 Project OptionsPHP Generator for MySQL allows you to specify default settings to be applied to eachgenerated webpage. By default, most of these options have the same values as theapplication options . All settings are grouped into several tabs.

    PageThe Page tab allows to modify the appearance of webpages, specify the script abilitiessuch as data formats available for data export, data view mode, data edit mode, datainsert mode and also delete, search and filter abilities. By default these settings are setin accordance with the Application options .

    Display formatsThese tab fields allow to adjust the display data formats in the way you need. Bydefault these settings are set in accordance with the Application options .

    Advanced op