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
- Is it fine to have foreign key as primary key?
- Importing data for advanced custom fields plugin?
- Custom form that store input in database
- Restoring WordPress posts from database only
- Can a post ID be 0?
- Issue with wp_insert_post and post_content field error Could not update post in the database
- wp_posts – guid update
- Migrating data between local and development server
- WordPress Database Charset/Collate
- Migrating non-WordPress CMS to WordPress, lots of data to move — possible solutions?
- storing database in version control
- Sub-domain or 2nd, temporary different domain?
- Delete all post meta except featured image
- Where is custom template file chosen for a post stored in the DB?
- How do i get user data from a custom table in the wordpress database by user ID?
- Converting WordPress into Android or iPhone app
- Safe way to find last inserted id in a table?
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- Importing Multiple DB to one MU database
- WordPress DATABASE Update Manually?
- How much of my site can I recover from public_html?
- I don’t see site_url and home_url fields in wp_options table (phpMyAdmin)?
- Multiple postmeta with same name for one post in wp_postmeta table
- Which is more efficient? Using usermeta, or creating a new MySQL table?
- Can I have multiple database users within WordPress?
- Structure of postmeta meta_value for woocommerce product download
- How to replicate a user plugin made table value, to this user’s custom meta table value?
- WordPress ‘repairing database’ in a constant error loop?
- WordPress returns to an old version
- Super slow queries from author archive pages killing my database
- localize elements in database
- How to fix database error duplicate entry
- Get value form wordpress database
- Moving to another server database connection error [closed]
- Best practice to limit results in get_row()?
- How to display content from external db with relevant urls
- Is there an easy way of exporting posts with their category already asigned and pictures from localhost?
- Connect to another WP install and grab post based on custom field
- Which table (and column) has the content of configured get_post_meta?
- Serialize data before inserting into the DB
- Pages from custom table
- content disappearing minutes after it’s published
- What is the most efficient way to reset a WordPress site?
- Optimizing function that automatically creates internal links based on post title string
- WordPress where clauses in db select
- How to display data from db in select list [closed]
- echo site_url() returns a different value than what is in the database siteurl field
- Native timestamp on wp_options option
- _wp_attachment_metadata is not being added to database when PDF files uploaded
- SELECT rows between two datetimes when the range is dynamic [closed]
- best way to upload a large file to wordpress using wp all import
- How do I loop/iterate through posts to edit all img tags?
- error establishing a database connection 3
- How to edit posts/pages without making the change live?
- Correct and secure way to access a custom SQL database in a custom PHP template file
- How to retrieve user data based on role using SQL?
- Does WordPress Support Using Named Pipes on the Windows Operating System?
- Store the wordpress “featured image” under »wp_posts« Database table
- Custom metabox does not store data
- wordpress database error
- How do i get value from wp_postmeta?
- Local host to server import problem
- I would like to import two columns into WordPress
- featured image not showing up with mysql_connect