TMySQLServer component

Previous  Top  Next

See Also Properties Methods Events Example
Unit
MySQLServer

Description

This is the main component in the MyComponent suite. The TMySQLServer is used to handle the actual connections to the MySQL Server using the driver specified. Most of the time you will use only one server component with multiple TMySQLDatasets/TMySQLTables/TMySQLQueries.

It is important to note that the server has only one physical connection/thread to the MySQL Server. All datasets attached to this TMySQLServer will use either this connection (see ShareConnection dataset property or dataset Options) or will spawn their own threaded connections using the same settings their TMySQLServer used to great the first connection. You are of course not limited to only one TMySQLServer per application and may create as many TMySQLServers as you please, each using the same or a different driver, each managing one shared connection/thread or many connections/threads for it's datasets.

Important properties:
·Drivers: DriverKind and DriverProperties  
·Connecting: Host, Port, Username and Password  
·Versioning: ClientVersion and ServerVersion  
·Listing of: GetDatabaseNames, GetTableNames and GetFieldNames  

The TMySQLServer also contain a unique ability to create and destroy datasets on request, or straight from an SQL statement on the fly. You can then reference these datasets (recordsets) by name, much like you would do in ASP or Visual Basic scripting. These methods also supported connecting the different datasets in master-detail relationships all with one method call. Please see Dataset/DatasetFrom and FreeDataset methods for more details.

Further more the TMySQLServer also implements the GET_LOCK and RELEASE_LOCK mysql functions for you, which you can use to easily form ad hoc locks between different similar client applications, see GetLock and ReleaseLock methods.

Designing your database and tables
One of the many nice features of the MyComponent suite is that it allows you to design your whole database structure right in the Delphi/Kylix IDE. All you have to do is specify the soAutoCreate Option for TMySQLServer as well as a DatabaseName, the soAutoCreate Option for the TMySQLDataset/Tables/Query as well as a TableName you wish to autocreate. Then design your columns using the FieldDefs property and your indexes using the IndexDefs property. For more information see, CreateDatabase, CreateTable, soDropIfExists, doDropIfExists, doCreateTemp for more information.