You can use Load data infile MySQL Query instead of looping through each entry.
Doc: https://dev.mysql.com/doc/refman/8.0/en/load-data.html
For example:
$wpdb->query(
$wpdb->prepare(
"LOAD DATA LOCAL INFILE %s INTO TABLE sas FIELDS TERMINATED BY ',' ENCLOSED BY %s IGNORE 1 LINES (@category,@temple) SET category = @category, temple = @temple;", $_FILES['file']['tmp_name'], '"'
)
);
Make sure that fields from file are properly mapped to those in DB. Also it will change as per your file formatting. Hope this helps.
Note: Please check for syntax error/ typos, code is not tried or tested.
Related Posts:
- What’s the database relationship between a post and its attachments
- Export WP database for import using WP-CLI on Vagrant Box
- Featured image from custom to WordPress database
- Why is my database import losing text widget data?
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- Best way to import users, post and categories from an external database
- How to create bulk page and content? [closed]
- Importing posts from old website to new conflicting post ID’s?
- When importing database, it shows error
- Is a direct or import approach safer for migration into WordPress?
- MySQL Syntax Error upon restoring database from backup [closed]
- Import live site to local setup without access to live site
- Error establishing a database connection; After importing DB & Theme
- WordPress database import: Row size too large
- Export / import WordPress database
- Bulk-create posts from SQL database
- Exporting table to csv works in the admin but exports HTML data when used on the front end
- Merging two databases without borking it
- Import users from old WP site to new one
- import posts with dutch/special letters
- Connection refused on locahost after importing database?
- Importing Direct to DB – GUID Question
- Best practice to import user base (subscribers) from one website to another?
- Importer fails to import every post
- Undo WooCommerce CSV import
- Import user data using CSV
- WordPress database products structure
- Is it good practice to import/export a blog to test a redesign?
- Realtime database update from 3rd party apps (notion, airtable, sheet, etc)
- How to map data on CSV to web pages?
- Updating database with CSV file and Cron job
- Extracted CSV as Array for Custom Query Loop
- import (migration) user database to wp-users
- Create CSV for import from File directories?
- I broke database after reuploading local version – what exactly happened? Database error
- Importing Concrete5 content to WordPress
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- phpMyAdmin – Error > Incorrect format parameter?
- Get error messages when $wpdb->insert() returns false?
- Does dbDelta delete columns as well?
- Insert data in database using form
- Special characters in WordPress UTF-8 [closed]
- Upload files – total size limit – WordPress/Contact Form 7
- Extend the wp_users table
- Relationship between performance and database size
- Importing large data from blogger
- Scheduling posts in database
- Should I be able to run two different “close” code versions of wordpress with the same DB
- Query from a different database than the default
- Need of separate security plugins for both root and subfolder sites WordPress?
- Escaping / encoding data before insert into a database?
- how to store arrays into a database
- Error: SELECT SQL_CALC_FOUND_ROWS
- WP All Import – Using Xpath to set a select value
- Switching database on the fly
- Replace/Mute/Stop Search Query
- Populate dropdown from database
- Finding the original login information in the database
- WordPress Database Huge wp_usermeta Table
- wp-cli search is returning ‘search’ is not a registered subcommand of ‘db’
- Localhost keeps redirecting to live domain
- How to get membershiplevel from WordPress Database?
- cache specific data?
- Child parent relationship inside WP DB
- Copying database tables to new database
- Duplicating Complete WordPress Install for Development and then Redeployment?
- Historic WordPress database connection
- $wpdb error (Call to a member function insert() on a non-object)
- How To Run A Temporary Instance Of a WordPress Backup Without a Database?
- Share users across multiple sites on same database, but with different domains
- Global__r connection timed out
- Moving WordPress site to new domain – database import [duplicate]
- Location of WP default mySQL tables creation file?
- Directly editing WP database issues
- Installation question
- Disable Database Update Required ? break my website
- phpMyAdmin error #1062 – Duplicate entry ‘1’ for key ‘PRIMARY’
- add_post_meta — not working
- Select From wpdb – Author/User Directory page
- How can I query the db to access current post information?
- Best Practice? – Saving multiple Values as Serialized Data / Saving each Value per Row / Dedicated Table
- Insert NULL value using prepare()
- How can I find user role in Mysql?
- $wpdb->insert duplicating rows
- Troubles when I want to connect to another DB
- Free version of Relevanssi doesn’t show ACF fields
- Communication in between WordPress database and another (not WordPress) database
- Is it possible to separate databases in WordPress site – one for orders and the other for all non-orders related
- Delete all users meta that named: user_avatar
- Using $wpdb to insert data into a table
- Accessing Information From Vendor Database On The Basis Of Customer Query
- spambot registering without providing email or password, bypassing registration process
- Issue “Error establishing a database connection” problem.
- Creating connections programmatically with common fields on CPT’s
- How to create 30 new sites from an export of a master site?
- Widgets with *internal* links do not display after database migration
- WordPress ERD mistake?
- Tool to check the database in Production [closed]
- How to solve notorious ‘Error Establishing a Database Connection’ [closed]
- Deleting WordPress posts and media files based on author via MYSQL database