我想在rest API中设置条件Order_BY例如("B"出现在"A"之前,"D"出现在"C"之前意味着输出是这样的"BADC")如果可能的话,请帮助我。
$get_entry_list_parameters = array(
//session id
'session' => $session_id,
//The name of the module from which to retrieve records
'module_name' => 'Accounts',
//The SQL WHERE clause without the word "where".
'query' => $query,
//The SQL ORDER BY clause without the phrase "order by".
'order_by' => " How to set Conditional Order By "
);
我猜你提到的BADC是列名。这应该用下面的代码来完成:
<?php
$order_by = $_POST['order_by']; // order_by's format is like this: B:asc;A:asc;D:desc;C:desc;
$order_by_str = ""; // to store a query statement for 'order by'
$order_by_array = explode(';', $order_by);
foreach ($order_by_array as $order_item) {
$order_item_array = explode(':', $order_item);
$order_by_str .= "," . $order_item_array[0] . " " . $order_item_array[1];
}
$order_by_str = substr($order_by_str, 1); // result for order_by
这是一个已知的错误。
缺陷66206:REST V4_1 API,函数get_entry_list不能使用order_by属性应用建议的修复对我有效