

To perform the conversion, simply use the following syntax: Once you build your template, simply save that file in the directory with the convert.php script and your source delimited file. INSERT INTO myTable (emp_num,fname,lname) VALUES (23456,JANE,DOE) INSERT INTO myTable (emp_num,fname,lname) VALUES (12345,JOHN,DOE) In this example, your output would look like this: INSERT INTO myTable (emp_num,fname,lname) VALUES (%employeeid%,%first_name%,%last_name%) However, if you want to build an SQL insert statement, you might build a template like this: Let's say we want to build an LDIF record to add all of the user records in our source file to our directory. In other words, our template will refer to the column names and the script will replace those tokens with the actual values from the source file.

The trick is that we will use the column labels from our source file as tokens in our template file. If you want to build and LDIF file, your template would be an LDIF statement. If you want to build an SQL statement with each record, your template file would be an SQL statement. The template file is something you construct to define how each record in your source delimited file should be transformed. An example file would something like this: You'll need to add a header row to your delimited text file that labels your columns. You can change the delimiter character by tweaking the "$delimiter" variable in line 2 of the convert.php script (delimiter is a comma by default). Your source file should be a delimited text file. This script is used at the command prompt so you'll need the php executable in your path. You'll need to put the attached script file on a machine with PHP installed (tested with PHP 5 but should work with PHP 4).
