简单的数据库结构:
如果我这样做:
SELECT info FROM `wp_participants_database` WHERE standard = '456' AND zertifikatsnummer = 'iso777' AND _firmennamen = 'Firma789';
我得到:“d”,这很好。
但是当我使用$wpdb
时,就像这里:
$query = "SELECT info FROM wp_participants_database WHERE standard = %d AND zertifikatsnummer = %d AND _firmennamen = %d";
$firmennamenx = $wpdb->get_row($wpdb->prepare( $query, '456', 'iso777', 'Firma789' ));
echo $firmennamenx->info;
我得到:“b”,为什么?
答案 0 :(得分:0)
尝试使用以下代码
let last10Day = Calendar.current.date(byAdding: .day, value: -10, to: Date())!
var interval = DateComponents()
interval.day = 1
let quantityType1 = HKQuantityType.quantityType(forIdentifier: HKQuantityTypeIdentifier.stepCount)!
// Create the query
let query = HKStatisticsCollectionQuery(quantityType: quantityType1,
quantitySamplePredicate: nil,
options: .cumulativeSum,
anchorDate: last10Day,
intervalComponents: interval)
// Set the results handler
query.initialResultsHandler = {
query, results, error in
guard let statsCollection = results else {
// Perform proper error handling here
fatalError("*** An error occurred while calculating the statistics: \(String(describing: error?.localizedDescription)) ***")
}
let endDate = Date()
statsCollection.enumerateStatistics(from: last10Day, to: endDate, with: { (statistics, stop) in
if let quantity = statistics.sumQuantity() {
let date = statistics.startDate
let value = quantity.doubleValue(for: HKUnit.count())
print("--value-->",value, ",--For Date-->",date)
}
})
}
healthStore.execute(query)
此处%d表示十进制值,%s表示字符串值。您的其他字段具有字符串值,因此您需要设置%s
希望现在你明白为什么你需要设置%s。