gpt4 book ai didi

ios - 我如何在解析 ios 中获取 AND 子句

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:16:41 25 4
gpt4 key购买 nike

我正在使用这个 link作为指南,但我可以弄清楚如何使用 AND 子句进行解析。它仅在示例代码中定义了 OR 子句。

如果我将它从 SQL 语句转换为它,它看起来像这样......

SELECT * FROM RemittanceTable WHERE beneCode = 'code' AND remittanceAmount = 500.00

例如在这段代码中,我想在读取数据之前检查代码和数量是否正确。但它用 OR 子句验证

PFQuery *beneCodeQuery = [PFQuery queryWithClassName:@"RemittanceTable"];
[beneCodeQuery whereKey:@"beneCode" containsString:_beneCodeText.text];

PFQuery *amountQuery = [PFQuery queryWithClassName:@"RemittanceTable"];
[amountQuery whereKey:@"remittanceAmount" equalTo:amount];

PFQuery *query = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects:beneCodeQuery,amountQuery,nil]];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
for (PFObject *object in objects) {
NSLog(@"%@", object);

[self resignAllResponder];
_paymentDetailsImage.frame = CGRectMake(_paymentDetailsImage.frame.origin.x, _paymentDetailsImage.frame.origin.y, _paymentDetailsImage.frame.size.width, paymentModeOrigHeight);
_detailsView.alpha = 1;

}
}}}];

最佳答案

每次添加约束时,它都隐含地使用 AND:

[query whereKey:@"username" equalTo:@"admin"];
[query whereKey:@"location" equalTo:@"USA"];

转换为“用户名 == 'admin' AND location == 'USA'”

更新

以您的具体情况为例:

PFQuery *beneCodeQuery = [PFQuery queryWithClassName:@"RemittanceTable"];
[beneCodeQuery whereKey:@"beneCode" containsString:_beneCodeText.text];
[beneCodeQuery whereKey:@"remittanceAmount" equalTo:amount];

NSArray *result = [beneCodeQuery findObjects];

关于ios - 我如何在解析 ios 中获取 AND 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22373026/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com