spires Posted September 1, 2006 Share Posted September 1, 2006 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 untillall the data is in.Any ideas please Link to comment https://forums.phpfreaks.com/topic/19354-inputing-multipul-data-at-once-into-a-database/ Share on other sites More sharing options...
pmeasham Posted September 1, 2006 Share Posted September 1, 2006 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 Link to comment https://forums.phpfreaks.com/topic/19354-inputing-multipul-data-at-once-into-a-database/#findComment-84083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.