KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Inserting data into MySQL using 4D MySQL Plugins
PRODUCT: 4D | VERSION: 2004 | PLATFORM: Mac & Win
Published On: November 23, 2004
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

4D for MySQL plugin allows the user to access the data and structure of a MySQL database without any pre-created ODBC data source. 4D for MySQL supports MySQL versions 3.23.XX - 4.0.X. The example below demonstrates how to connect to a MySQL database and insert data into a table using 4D for MySQL plugin.

  `Method inserting data in MySQL using 4D for MySQL Plugin

C_LONGINT($connectionid)

  `Establishes a connection for MySQL
$connectionid:=MySQL_Connect ("Server address";"Database name";"User name";"Password")

If ($connectionid#0)

`Executes a MySQL insert statement to insert data into the database
  MySQL_Execute ($connectionid;"Insert into tablename (field1,field2) values ('field1value','field2value')")

`Closes the connection
  MySQL_Close ($connectionid)
Else
  ALERT("Connection Failed !")
End if