千萬的數據量傳遞,會導致內存泄漏。
最好的方式,是在外層用shell腳本進行控制,先用shell讀取php腳本獲取總頁數,
然后,通過shell循環,每一個循環開啟一個php進程,進行本頁數據的同步,
同步后,進程處理結束,shell進行下一個循環,是一個新的php進程,這樣,千萬數據也沒事,你可以每頁處理1000行,照樣用AR。
如:
#!/bin/sh Cur_Dir=$(cd `dirname $0`; pwd) # get product all count. count=`$Cur_Dir/yii order/order/orderstatuscount` echo "There are $count Order to process" echo "##############ALL BEGINING###############"; start=0 for (( i=1; i<=$count; i++ )) do start=`$Cur_Dir/yii order/order/syncorderstatus $start` echo "Order_id $start done" done echo "##############ALL COMPLETE###############";
