I'm passing a large dataset into a MySQL table via PHP using insert commands and I'm wondering if its possible to insert approximately 1000 rows at a time via a query other than appending each value on the end of a mile long string and then executing it. I am using the CodeIgniter framework so its functions are also available to me.
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
You could always use mysql's
LOAD DATA
:to do bulk inserts rather than using a bunch of
INSERT
statements.You can do it with several ways in codeigniter e.g.
I have created a class that performs multi-line that is used as follows:
where the class is defined as follows:
You could prepare the query for inserting one row using the mysqli_stmt class, and then iterate over the array of data. Something like:
Where 'idsb' are the types of the data you're binding (int, double, string, blob).