Framework
3.9
|
CSVImport provides a generic method for importing Comma-Separated Value files into DataItem mapped database tables. More...
Public Member Functions | |
__construct ($class) | |
import ($file=null) | |
drawForm () | |
Public Attributes | |
$class | |
$index_field = null | |
$truncate = false | |
$update = false | |
$ignoreUnknown = false | |
$disablePrimaryKey = false | |
$onPreImport = null | |
$onPostImport = null | |
$lines = 0 | |
$imported = 0 | |
$limit = -1 | |
$tx | |
CSVImport provides a generic method for importing Comma-Separated Value files into DataItem mapped database tables.
These files can be easily exported from Excel, Access and other office and database applications.
In order to use a CSV file for an import it must contain a first row with the column names being the associated field names in your target DataItem.
To use this class, instantiate it with the name of the DataItem class you will be importing. You can set various options to manage the import.
index_field specifies which field is used to determine the identity of matching items already in the database
truncate specifies whether you want to truncate the database table before importing the data.
update specifies whether data in the import file should update matching items already in the database. If set to false then matching import records are skipped
onPreImportItem is a callback function that is called for each item after the data values have been read from the file but before the item has been persisted to the database. You can use this callback to manipulate fields during the import process.
onPostImportItem is a callback function that is called for each item after persisting in the database. You can use this callback to perform additional manipulation, such as building cross-reference records.
ignoreUnknown this flag specifies whether an error should be thrown if columns are found in the CSV file that do not match defined database fields in your DataItem object.
Definition at line 74 of file csv_import.inc.
CSVImport::__construct | ( | $class | ) |
Definition at line 89 of file csv_import.inc.
CSVImport::drawForm | ( | ) |
Definition at line 236 of file csv_import.inc.
CSVImport::import | ( | $file = null | ) |
Definition at line 94 of file csv_import.inc.
CSVImport::$class |
Definition at line 76 of file csv_import.inc.
CSVImport::$disablePrimaryKey = false |
Definition at line 81 of file csv_import.inc.
CSVImport::$ignoreUnknown = false |
Definition at line 80 of file csv_import.inc.
CSVImport::$imported = 0 |
Definition at line 85 of file csv_import.inc.
CSVImport::$index_field = null |
Definition at line 77 of file csv_import.inc.
CSVImport::$limit = -1 |
Definition at line 86 of file csv_import.inc.
CSVImport::$lines = 0 |
Definition at line 84 of file csv_import.inc.
CSVImport::$onPostImport = null |
Definition at line 83 of file csv_import.inc.
CSVImport::$onPreImport = null |
Definition at line 82 of file csv_import.inc.
CSVImport::$truncate = false |
Definition at line 78 of file csv_import.inc.
CSVImport::$tx |
Definition at line 87 of file csv_import.inc.
CSVImport::$update = false |
Definition at line 79 of file csv_import.inc.