Copy CodeThe code is as follows:
Public Function Insertuser ($userArray) {
foreach ($userArray as $key = = $value) {
@ $field. = "$key,";
@ $content. = "' $value ',";
}
$field = Ereg_replace (', $ ', ', $field);
$content = Ereg_replace (', $ ', ', $content);
$db = Db_connect (); Connecting to a database
$db->autocommit (FALSE); Set to non-auto commit--transaction processing
$sql 1 = "INSERT into T_user (". $field. ") VALUES (". $content.") ";
$result 1 = $db->query ($sql 1);
$sql 2 = "INSERT into T_userpost (f_username) VALUES ('". $userArray [' F_username ']. "')";
$result 2 = $db->query ($sql 2);
if ($result 1 && $result 2) {
$db->commit (); All successful, submit execution results
echo ' Submit ';
} else {
$db->rollback (); Any error occurred, rollback and cancel execution result
echo ' rollback ';
}
$db->close ();
}
http://www.bkjia.com/PHPjc/321765.html www.bkjia.com true http://www.bkjia.com/PHPjc/321765.html techarticle Copy the code code as follows: Public function Insertuser ($userArray) {foreach ($userArray as $key = $value) {@ $field. = "$key,"; @ $cont Ent. = "' $value ',"; } $field = Ereg_replace (',...