PHsPeed contains a lot of functionality for working with databases. To be able to use this functionality there are the following requirements:


  • The IDE must be able to access the database (for metadata). By default the IDE is able to connect to SQlite, MySQL and MariaDB. For other databases you must have installed the correct database driver(s) to be able to connect.
  • PHP must be able to connect to the database. This means that you have to setup your environment with the appropriate PDO drivers. For SQLite, MySQL and MariaDB this is default, but you must enable the correct pdo drivers in the PHP.ini.


Before diving into the details, it is important to have  a little understanding of the PHsPeed architecture. PHsPeed makes use of PDO for connecting to the database. Although PHP contains API’s for the several databases, using it, makes an application database dependent. Using PDO as a database independent layer does not automatically mean that you can access each and every database without changing things (unfortunately SQL is not that standard), but it sure makes the amount of changes way easier. And PDO is supported by al major database suppliers. Some additional note is necessary for MsSQL, there is a native and a ADO driver available. We have tested PHsPeed with the ADO driver as the native driver caused too many issues. Especially to find the correct version for the used MsSQL database version. For other databases that do not support PDO, but that do support ODBC, you can use the PDO-ODBC connector. OpenEdge uses an ADO/ODBC driver by default.


Within your application you have to supply SQL to the database components. You can do that by entering the full statement or by using an SQL designer. But if you use database specific constructs like cube functions, roll-up etc. then be aware that different databases use different syntax. If you must create a real database independent application that can virtually run on any database with the same code-base, then you must be careful in your SQL.

Remark:

The database (and PDO) is configured in the IDE and is independent from your project. In general this is only a one-time step.



The DBConnection is a component that finds the configuration in your IDE and copies it into the PHP application. That is important to remember, because if you change things in your configuration, this will not be automatically set into your connection components of all the modules in your project. Use the bulk-edit function to set the new connection.


The setting here is completely independent from the setting in your production environment. When you want to deploy your application then you have a choice how to maintain the default database connection parameters. 


  1. Traditional with a (readable) configuration file
  2. Use embedded function to create an encrypted configuration file
  3. Manual by intercepting the connection event


The DBConnection component is necessary for each different connection. So if you use two different databases, then you must use two different DBConnection components. This means that you can also use diffent database types in one application.