我正在尝试从多行检索多个数据...我发现了这段代码并得到了一些我不理解的结果。任何人都可以检查并告诉我它是否正确以后我想将这些多重结果显示到android应用程序内的listview中......这也是正确的吗?
为了进行测试,我使用postman运行此代码并获得此结果Screen Shot
在这里你可以检查我的PHP代码:
我的DbOperations.php
<?php
require_once '../include/DbOperations.php';
$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){
if(isset($_POST['reg_pin'])){
$db = new DbOperations();
$test_category = $db->gettestuser($_POST['reg_pin'], $_POST['reg_a'], $_POST['reg_b'], $_POST['reg_ho'], $_POST['reg_ll'], $_POST['reg_c'], $_POST['reg_d']);
var_dump($test_category);
$response['error'] = false;
$response['pid'] = $test_category['pid'];
$response['name'] = $test_category['name'];
$response['pin'] = $test_category['pin'];
$response['a'] = $test_category['a'];
$response['b'] = $test_category['b'];
$response['ho'] = $test_category['ho'];
$response['ll'] = $test_category['ll'];
$response['c'] = $test_category['c'];
$response['d'] = $test_category['d'];
}else{
$response['error'] = true;
$response['message'] = "Required fields are missing";
}
}
echo json_encode($response);
?>
我的gettestuser.php
select ...
from ...
where (a,b) in ( ('a1','b1'), ('a2','b5'), ('a3','b2') );
答案 0 :(得分:1)
评论太长了。
以下是使用括号的查询示例...
SELECT *
FROM test_category
WHERE name = ?
AND (a = ? Or b = ?)
OR (ho = ? Or ll = ?)
OR (c = ? Or d = ?);