如何在foreach中选择MySQL?
我的代码是:
GetMembersToExpandNames
注意:我想要public static class Expand {
public static string[] GetMembersToExpandNames(ODataQueryOptions options) {
return GetExpandPropertyPaths(GetExpandItems(options?.SelectExpand?.SelectExpandClause)).ToArray();
}
private static IEnumerable<string> GetExpandPropertyPaths(IEnumerable<ExpandedNavigationSelectItem> items, string prefix = "") {
foreach(var item in items) {
foreach(var res in GetExpandPropertyPaths(item, prefix)) {
yield return res;
}
}
}
private static IEnumerable<string> GetExpandPropertyPaths(ExpandedNavigationSelectItem item, string prefix = "") {
var curPropName = item.NavigationSource.Name;
var nestedExpand = GetExpandItems(item.SelectAndExpand).ToArray();
if(nestedExpand.Count() > 0) {
foreach(var res in GetExpandPropertyPaths(nestedExpand, $"{prefix}{curPropName}.")) {
yield return res;
}
} else {
yield return $"{prefix}{curPropName}";
}
}
private static IEnumerable<ExpandedNavigationSelectItem> GetExpandItems(SelectExpandClause sec) {
if(sec != null) {
var res = sec?.SelectedItems?.OfType<ExpandedNavigationSelectItem>();
if(res != null) {
return res;
}
}
return new ExpandedNavigationSelectItem[0];
}
}
答案 0 :(得分:-1)
$start = new DateTime($giris);
$end = new DateTime($cikis);
$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($start, $interval, $end);
foreach ($period as $dt) {
$datex = $dt->format("Y-m-d"). PHP_EOL;
$sorgu = mysql_query("SELECT * FROM takvimler WHERE `date`='$datex'");
$veri = mysql_fetch_assoc($sorgu);
$don .= $veri['price'];
}
echo $don;