Creating a PHP MySQL data source
The GoLive dynamic content support for PHP currently supports the MySQL database. Other databases can be supported using the GoLive SDK to extend GoLive. One consequence of this is that no drivers are required except that PHP must have the MySQL support module enabled.
To set up a MySQL data source in your PHP site: Note: You need to have your site set up as a dynamic site. (See Making a Web site dynamic.) - With the site window active, select the Site Settings > Dynamic Content pane.
- In the Data Sources area, click New.
- Select MySQL Database, and click Add Data Source.
- In the MySQL Data Source editor, fill in the fields as follows:
- Data Source Name: Choose a name for this data source. The database name that it refers to is usually a good choice. This must be a legal filename on the Web server and the machine where GoLive is running.
- Host: Enter the name of the machine on which MySQL is running. This is not a URL, it is a simple machine name, or a simple machine name followed by a colon and a port number. The default port used by MySQL is 3306. If MySQL is running on the same machine as the Web server, you can leave this field blank or use the string localhost. If MySQL is running on a different machine from the Web server, be sure to set network database access permissions in the MySQL database to allow remote access. Consult the MySQL documentation for details on how to do this.
- Database: Enter the name of the database within MySQL that you wish to access. MySQL can support multiple databases on a single server.
- User and Password: If a specific identity is required to access the database, enter the username and password here.
Note: The password is stored in clear text in the data source file. Be sure that HTTP Read access is not allowed to the config/datasources folder to restrict visibility of this file. (See Relocating config/datasources folder.) - Press the Test button to test the data source. Test will make a call to the Web server and try to connect to the database. If successful, it will return and display an XML representation of the list of tables that were discovered in the database. If an error occurs, some error information will be displayed if possible. Unfortunately, depending on the database system and driver, the content of the error messages may be very obscure.
|