我有一个数组包含动态生成的文本框值的结果集。
在下面的示例中,我创建了三个动态生成的行,每行包含6个文本字段。为区分每一行名称,我将行id添加为名称的最后一个单词。示例ClaimExecutionCountry1
表示ClaimExecutionCountry
作为名称,1
表示行ID。
Array
(
[0] => ClaimExecutionCountry1=10
[1] => activitystartdate1=05-27-2016
[2] => activityenddate1=06-24-2016
[3] => CLCode1=CLC1
[4] => SCSCode1=SCS1
[5] => fileName1=calc2.png
[6] => ClaimExecutionCountry2=53
[7] => activitystartdate2=05-27-2016
[8] => activityenddate2=05-28-2016
[9] => CLCode2=
[10] => SCSCode2=
[11] => fileName2=gh.png
[12] => ClaimExecutionCountry3=82
[13] => activitystartdate3=05-26-2016
[14] => activityenddate3=07-28-2016
[15] => CLCode3=
[16] => SCSCode3=SCS5
[17] => fileName3=preview1.png
)
我面临一个问题,就是将这些值存储在数据库中。我的数据库结构在下面
Id | ClaimExecutionCountry | activitystartdate | activityenddate | CLCode | SCSCode | fileName
我需要在此表中存储=
个符号值。
,结果为
Id | ClaimExecutionCountry | activitystartdate | activityenddate | CLCode | SCSCode | fileName
------------------------------------------------------------------------------------------------------------
1 | 10 | 05-27-2016 | 06-24-2016 | CLC1 | SCS1 | calc2.png
2 | 53 | 05-27-2016 | 05-28-2016 | null | null | gh.png
3 | 82 | 05-26-2016 | 07-28-2016 | null | SCS5 | preview1.png
所以任何人都可以帮我用以上格式将数组值存储在数据库中。我想你了解我的问题。我使用PHP,codignator和MySql作为数据库。提前致谢
答案 0 :(得分:0)
请尝试以下代码:
$_array=Array(
[0] => ClaimExecutionCountry1=10
[1] => activitystartdate1=05-27-2016
[2] => activityenddate1=06-24-2016
[3] => CLCode1=CLC1
[4] => SCSCode1=SCS1
[5] => fileName1=calc2.png
[6] => ClaimExecutionCountry2=53
[7] => activitystartdate2=05-27-2016
[8] => activityenddate2=05-28-2016
[9] => CLCode2=
[10] => SCSCode2=
[11] => fileName2=gh.png
[12] => ClaimExecutionCountry3=82
[13] => activitystartdate3=05-26-2016
[14] => activityenddate3=07-28-2016
[15] => CLCode3=
[16] => SCSCode3=SCS5
[17] => fileName3=preview1.png
)
foreach($_array as $val){
$a = explode("=",$val);
$field = $a[0];
$ans=$a[1];
$matches = array();
if (preg_match('#(\d+)$#', $field, $matches)) {
$rowNum=$matches[1];
}
$fieldName = str_replace($rowNum,"",$field);
/*Now you have number of row , $fieldName , $rowNum and $ans so we can execute SQl statement inside forEach*/
}
希望它会对你有所帮助。
答案 1 :(得分:0)
fbeta <- function(x) dbeta(x,alpha,beta)
maxibeta <- optimize(fbeta, interval = c(0,1), maximum = TRUE)$objective
histo <- hist((data-min(data)) / (max(data)-min(data)), plot = FALSE)
plot(histo, freq=FALSE, col="grey", border="white",
ylim=c(0, max(maxibeta, max(histo$density))),
main="Histogram + fitted distribution")
plot(fbeta, add=TRUE, col=2, lwd=2)