我有幾個需要插入數據庫的大表單。使大的Mysqli插入效率更高
我目前做這樣
$stmt = $memberMysqli->prepare("INSERT INTO questionnairebespokeexerciseplan(userid,date,naturalbodytype,framesizewrist,framesizeelbow,fitnessgoals,workpattern,sleephours,runningbarriers,workcommute,workdistance,smoke,biomechanicalissues,limitingillness,reletivesheartproblems,birthlast12months,recurringinjuries,regularmedication,pregnant,anythingelsehealth,gymmember,runoutdoors,wouldyouliketorunoutdoors,homeequipments,whattypeequipment,exercisetime,heartratemonitor,restingheartrate,actualheartrate,maxheartrate,heartratesteadyrun,heartratebreathless,trainingshoes,preferredexercisetype,exerciseclasses,classdays,bike,bikemodel,runlunchtimebeforework,clubmember,clubschedule,personaltraining,otherheartrate,foottype) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$stmt->bind_param('ssssssssssssssssssssssssssssssssssssssssssss',
$_POST['userid'],
$date,
$_POST['naturalbodytype'],
$_POST['framesizewrist'],
$_POST['framesizeelbow'],
$_POST['fitnessgoals'],
$_POST['workpattern'],
$_POST['sleep'],
$_POST['runbarriers'],
$_POST['workcommute'],
$_POST['workmiles'],
$_POST['smoke'],
$_POST['biomechanical'],
$_POST['illnesses'],
$_POST['heartcondition'],
$_POST['givenbirth'],
$_POST['injuries'],
$_POST['medication'],
$_POST['pregnant'],
$_POST['anythingelse'],
$_POST['gymmember'],
$_POST['runoutdoors'],
$_POST['liketorunoutside'],
$_POST['homeequipment'],
$_POST['equipment'],
$_POST['besttime'],
$_POST['heartratemonitor'],
$_POST['restingheartrate'],
$_POST['actualheartrate'],
$_POST['actualmaxheartrate'],
$_POST['heartratesteadyrun'],
$_POST['heartratebreathless'],
$_POST['trainingshoes'],
$_POST['preferredexersize'],
$_POST['classes'],
$_POST['classdays'],
$_POST['bike'],
$_POST['whatbike'],
$_POST['beforeworklunchtime'],
$_POST['clubmember'],
$_POST['clubschedule'],
$_POST['personaltrainer'],
$_POST['otherheartrate'],
$_POST['foottype']
);
,如果有這樣做的更好/更直接的方式,我只是在想什麼?
由於目前需要一些時間來創建和調試它,當事情不正確時也同樣耗時。
Eval ?! Yikes ... – 2013-03-25 19:40:07
正如在PHP手冊上看到的,83%喜歡:http://www.php.net/manual/en/mysqli-stmt.fetch.php#107034 – olli 2013-03-25 20:12:06