Class WPDA_Import_File

Loads the content of an import file and imports it.

author Peter Schulz
since 1.0.0
package WPDataAccess\Utilities


WPDA_Import constructor

__construct(string $file_path) 

Create file pointer.

since 1.0.0




Full path of script (import) file.

Close file.

since 2.0.12

Import file content

import(string $schema_name, string $table_name, string $hide_errors) 

Import method writes the content of the import file to the database. Security checks:

  • Only INSERT INTO is allowed: no other DML, DDL and DCL statements allowed
  • Only inserts into the table name provided are allowed
  • Use explain to check the number of tables affect: more than 1 looks like SQL injection

Since wpdb-query() only processes one query at a time we only need to check the type of statement at the beginning of the script ($file_content).

This method only return -1 if a failure occurs or the number of rows inserted. The number of probable error cause is to huge and complex to check all possibilities. Exports created from the WP Data Access table list should normally import without problems. For manually created imports responsibility is with the developer.

since 1.0.0




Schema in which this import allowes inserts.



Table in which this import allowes inserts.



ON = hide errors, OFF = show errors.



Content of import file

$file_content : string



Pointer to import file

$file_pointer : string