新聞中心
php 怎么解決 大數(shù)據(jù)量 插入數(shù)據(jù)庫
ini_set('max_execution_time','0');
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比盧氏網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式盧氏網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋盧氏地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。
$pdo
=
new
PDO("mysql:host=localhost;dbname=test","root","123456");
$sql
=
"insert
into
test(name,age,state,created_time)
values";
for($i=0;
$i100000;
$i++){
$sql
.="('zhangsan',21,1,'2015-09-17')";
}
$sql
=
substr($sql,0,strlen($sql)-1);
var_dump($sql);
if($pdo
-
exec($sql)){
echo
"插入成功!";
echo
$pdo
-
lastinsertid();
}
試試吧。10萬條1分鐘多,我覺得還行
php 接收到之后post數(shù)據(jù)寫入數(shù)據(jù)庫
form表單demo:task.html
fieldset id="setFiled"
legend發(fā)布任務(wù)/legend
form action="registr.php" method="post" id="steForm"
label任務(wù)類型:/labelbr
input type="text" name="type"? id="taskType" placeholder="請選擇任務(wù)類型"/br
label酬nbsp;nbsp;金:/labelbr
input type="number" name="money" id="forMoney" min="1" max="1000"/label元/labelbr
label截止時間:/labelbr
input type="datetime" name="time" id="timeSubmit"/span data-year="" data-month="" data-date="" id="showDate"/spanbr
label詳細(xì)描述:/labelbr
textarea maxlength="512" name="textAray" id="msgArea"/textareabr
input type="submit" name="subMit" id="forSub" value="點(diǎn)擊發(fā)布" /
/form
擴(kuò)展資料
php接收POST數(shù)據(jù)的三種方式
1、$_POST 方式接受數(shù)據(jù)
$_POST 方式是由通過HTTP的POST方法傳遞過來的數(shù)據(jù)組成的數(shù)組,是一個自動全局變量。
注:只能接收Content-Type:application/x-www-form-urlencode提交的數(shù)據(jù)。也就是只能接收表單過來的數(shù)據(jù)。
2、GLOBLES[‘HTTP_RAW_POST_DATA’]
如果訪問原始POST數(shù)據(jù)不是php能夠識別的文檔類型,比如:text/xml 或者soap等等,可以用$GLOBLES[‘HTTP_RAW_POST_DATA’]來接收,$HTTP_RAW_POST_DATA變量包含有原始POST數(shù)據(jù)。此變量僅在碰到未識別的MIME數(shù)據(jù)時產(chǎn)生。
注:$HTTP_RAW_POST_DATA對于enctype=”multipart/form-data”表單數(shù)據(jù)不可用,也就是說使用$HTTP_RAW_POST_DATA無法接受網(wǎng)頁表單post過來的數(shù)據(jù)。
3、file_get_contents(“php://input”);
如果訪問原始POST數(shù)據(jù),更好的方法是使用file_get_content(“php://input”);對于未指定Content-Type的POST數(shù)據(jù),可以使用該方法讀取POST原始數(shù)據(jù),包括二進(jìn)制流也可以和$HTTP_RAW_POST_DATA比起來。它帶來的生存眼里更小,并且不需要任何特殊的php.ini設(shè)置。
注:php://input不能用于 enctype=”multipart/form-data”
例如:$postStr = file_get_contents("php://input"); //獲取POST數(shù)據(jù)
php怎么把數(shù)據(jù)導(dǎo)入數(shù)據(jù)庫
需要PHP基礎(chǔ)知識和數(shù)據(jù)庫基礎(chǔ)知識。
以SQL為例。使用PHP MySQL 函數(shù)可以編輯數(shù)據(jù)庫。
mysql_connect() 函數(shù)打開MySQL 連接。舉例
?php
$con = mysql_connect("localhost","mysql_user","mysql_pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}// 一些代碼...mysql_close($con);
?
mysql_connect()三個參數(shù)分別是服務(wù)器名,連接賬號,連接密碼。
連接之后,可以使用mysql_select_db()設(shè)置要處理的數(shù)據(jù)庫,后面則是用數(shù)據(jù)庫語句處理數(shù)據(jù)。SQL語法簡介網(wǎng)頁鏈接
本文題目:php大數(shù)據(jù)寫入數(shù)據(jù)庫 php大數(shù)據(jù)導(dǎo)出
文章URL:http://fisionsoft.com.cn/article/doeiooj.html