Jump to content

Archived

This topic is now archived and is closed to further replies.

spires

inputing multipul data at once into a database

Recommended Posts

Hi,

Does any know how to add more than one row into your database at the same time?

I'm guessing it would be some kind of four loop that keeps looping over the INSERT untill
all the data is in.

Any ideas please

Share this post


Link to post
Share on other sites
you can do this with sql:

INSERT INTO `table` VALUES ('data1a','data1b'),('data2a','data2b'),('data3a','data3b')

You can do this with php using multi database querys as well, however I'd look into using a database abstraction layer.
eg from pears:

[code]
$sth = $db->prepare('INSERT INTO numbers VALUES (?, ?, ?)');
$alldata = array(array(1, 'one', 'en'),
                array(2, 'two', 'to'),
                array(3, 'three', 'tre'),
                array(4, 'four', 'fire'));
$res =& $db->executeMultiple($sth, $alldata);
[/code]

see: http://pear.php.net/package/DB

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.